diff options
author | jstebbins <[email protected]> | 2008-09-02 22:56:19 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2008-09-02 22:56:19 +0000 |
commit | 45cabbfe4ab8b95b5f25a236f8c93b64d3ccf8df (patch) | |
tree | 40326771d4a7f4721363e3b76ebfca5329595deb /gtk/src/preset_to_string.c | |
parent | fd744170cb1da2675e1168402866f5c20f08a726 (diff) |
LinGui: Presets and preferences are now stored as plists
This will also make saving/restoring the queue much easier.
It's a scary big change. 1400 new lines of code. Due to efficiencies
of a better desing, 2400 lines of old code also gets refactored
down to 1600. Giving a final net +600 lines.
Along the way, I stumbled across a couple bugs and fixed them.
Chapter list entry would get wedged under certain circumstances.
Pausing encoding didn't display pause message in status bar.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1662 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src/preset_to_string.c')
-rw-r--r-- | gtk/src/preset_to_string.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/gtk/src/preset_to_string.c b/gtk/src/preset_to_string.c index e678e994b..e1816637b 100644 --- a/gtk/src/preset_to_string.c +++ b/gtk/src/preset_to_string.c @@ -16,7 +16,8 @@ int main(int argc, char *argv[]) { FILE *infile, *outfile; - char buffer[BUF_SIZE]; + char in_buffer[BUF_SIZE]; + char out_buffer[2*BUF_SIZE]; if (argc < 2 || argc > 3) { @@ -32,17 +33,31 @@ main(int argc, char *argv[]) { outfile = fopen(argv[2], "w"); } - while (fgets(buffer, BUF_SIZE, infile) != NULL) + while (fgets(in_buffer, BUF_SIZE, infile) != NULL) { + int ii, jj; int len; // Step on any CR LF at end of line - len = strlen(buffer); - if (buffer[len-1] == '\n' || buffer[len-1] == '\r') - buffer[len-1] = 0; - if (buffer[len-2] == '\n' || buffer[len-2] == '\r') - buffer[len-2] = 0; - fprintf(outfile, "\"%s\\n\"\n", buffer); + len = strlen(in_buffer); + for (jj = 0, ii = 0; ii < len; ii++) + { + if (in_buffer[ii] == '"') + { + out_buffer[jj++] = '\\'; + out_buffer[jj++] = in_buffer[ii]; + } + else if (in_buffer[ii] == '\n' || in_buffer[ii] == '\r') + { // Skip it + } + else + { + out_buffer[jj++] = in_buffer[ii]; + } + } + out_buffer[jj] = 0; + fprintf(outfile, "\"%s\\n\"\n", out_buffer); } - close(infile); - close(outfile); + fclose(infile); + fclose(outfile); + return 0; } |