summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3-main.h
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2007-02-11 02:16:27 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2007-02-11 02:16:27 +0000
commita5f03073f9a5ce6f25255566803f9ad9fcf1c469 (patch)
tree5d4447b2d0b7995cdfebc7a005c17e52f7fab0f8 /xdelta3/xdelta3-main.h
parente6a4d603ed05dd9d7e04311ef351700b60852dae (diff)
Fixes bugs in XDELTA environment variable.
Removes stream.srcwin_size variable, uses stream.src->blksize instead, to address performance regression from xdelta1. Changes the order of checksum computation to be like xdelta1, insert checksums in reverse to give preference to earlier matches. Removes svn:executable from files.
Diffstat (limited to 'xdelta3/xdelta3-main.h')
-rw-r--r--[-rwxr-xr-x]xdelta3/xdelta3-main.h52
1 files changed, 39 insertions, 13 deletions
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index 1552809..7ccd63b 100755..100644
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -346,7 +346,6 @@ main_config (void)
346 P(RINT "XD3_ALLOCSIZE=%d\n", XD3_ALLOCSIZE); 346 P(RINT "XD3_ALLOCSIZE=%d\n", XD3_ALLOCSIZE);
347 P(RINT "XD3_DEBUG=%d\n", XD3_DEBUG); 347 P(RINT "XD3_DEBUG=%d\n", XD3_DEBUG);
348 P(RINT "XD3_DEFAULT_LEVEL=%d\n", XD3_DEFAULT_LEVEL); 348 P(RINT "XD3_DEFAULT_LEVEL=%d\n", XD3_DEFAULT_LEVEL);
349 P(RINT "XD3_DEFAULT_CKSUM_SIZE=%d\n", XD3_DEFAULT_CKSUM_ADVANCE);
350 P(RINT "XD3_DEFAULT_IOPT_SIZE=%d\n", XD3_DEFAULT_IOPT_SIZE); 349 P(RINT "XD3_DEFAULT_IOPT_SIZE=%d\n", XD3_DEFAULT_IOPT_SIZE);
351 P(RINT "XD3_DEFAULT_SPREVSZ=%d\n", XD3_DEFAULT_SPREVSZ); 350 P(RINT "XD3_DEFAULT_SPREVSZ=%d\n", XD3_DEFAULT_SPREVSZ);
352 P(RINT "XD3_DEFAULT_SRCWINSZ=%d\n", XD3_DEFAULT_SRCWINSZ); 351 P(RINT "XD3_DEFAULT_SRCWINSZ=%d\n", XD3_DEFAULT_SRCWINSZ);
@@ -742,7 +741,13 @@ main_file_open (main_file *xfile, const char* name, int mode)
742 741
743 xfile->mode = mode; 742 xfile->mode = mode;
744 743
744 XD3_ASSERT (name != NULL);
745 XD3_ASSERT (! main_file_isopen (xfile)); 745 XD3_ASSERT (! main_file_isopen (xfile));
746 if (name[0] == 0)
747 {
748 XPR(NT "invalid file name: empty string\n");
749 return XD3_INVALID;
750 }
746 751
747#if XD3_STDIO 752#if XD3_STDIO
748 xfile->file = fopen (name, XOPEN_STDIO); 753 xfile->file = fopen (name, XOPEN_STDIO);
@@ -1840,6 +1845,12 @@ main_get_appheader_params (main_file *file, char **parsed, int output, const cha
1840 1845
1841 if (other->filename != NULL) { 1846 if (other->filename != NULL) {
1842 /* Take directory from the other file, if it has one. */ 1847 /* Take directory from the other file, if it has one. */
1848 /* TODO: This results in nonsense names like /dev/foo.tar.gz
1849 * and probably the filename-default logic interferes with
1850 * multi-file operation and the standard file extension?
1851 * Possibly the name header is bad, should be off by default.
1852 * Possibly we just want to remember external/compression
1853 * settings. */
1843 char *last_slash = strrchr(other->filename, '/'); 1854 char *last_slash = strrchr(other->filename, '/');
1844 1855
1845 if (last_slash != NULL) { 1856 if (last_slash != NULL) {
@@ -2029,17 +2040,25 @@ main_set_source (xd3_stream *stream, int cmd, main_file *sfile, xd3_source *sour
2029 sfile->nread = 0; 2040 sfile->nread = 0;
2030 source->size = UINT64_MAX; 2041 source->size = UINT64_MAX;
2031 } 2042 }
2032 else if ((ret = main_file_open (sfile, sfile->filename, XO_READ)) || 2043 else
2033 (ret = main_file_stat (sfile, & source->size, 1)))
2034 { 2044 {
2035 goto error; 2045 if (option_verbose)
2046 {
2047 XPR(NT "source file: %s\n", sfile->filename);
2048 }
2049
2050 if ((ret = main_file_open (sfile, sfile->filename, XO_READ)) ||
2051 (ret = main_file_stat (sfile, & source->size, 1)))
2052 {
2053 goto error;
2054 }
2036 } 2055 }
2037 2056
2038 source->name = sfile->filename; 2057 source->name = sfile->filename;
2039 source->ioh = sfile; 2058 source->ioh = sfile;
2040 source->curblkno = (xoff_t) -1; 2059 source->curblkno = (xoff_t) -1;
2041 source->curblk = NULL; 2060 source->curblk = NULL;
2042 2061
2043#if EXTERNAL_COMPRESSION 2062#if EXTERNAL_COMPRESSION
2044 if (option_decompress_inputs) 2063 if (option_decompress_inputs)
2045 { 2064 {
@@ -2650,7 +2669,7 @@ main_input (xd3_cmd cmd,
2650 } 2669 }
2651 2670
2652 /* Limited instruction buffer size affects source copies */ 2671 /* Limited instruction buffer size affects source copies */
2653 if (stream.i_slots_used > stream.iopt_size) 2672 if (option_verbose > 1 && stream.i_slots_used > stream.iopt_size)
2654 { 2673 {
2655 XPR(NT "warning: input position %"Q"u overflowed instruction buffer, " 2674 XPR(NT "warning: input position %"Q"u overflowed instruction buffer, "
2656 "needed %u (vs. %u)\n", 2675 "needed %u (vs. %u)\n",
@@ -2831,7 +2850,7 @@ setup_environment (int argc,
2831 (*env_free) = main_malloc(strlen(v) + 1); 2850 (*env_free) = main_malloc(strlen(v) + 1);
2832 strcpy(*env_free, v); 2851 strcpy(*env_free, v);
2833 2852
2834 /* Space needed for new argv: count spaces */ 2853 /* Space needed for extra args, at least # of spaces */
2835 n = argc + 1; 2854 n = argc + 1;
2836 for (p = *env_free; *p != 0; ) { 2855 for (p = *env_free; *p != 0; ) {
2837 if (*p++ == ' ') { 2856 if (*p++ == ' ') {
@@ -2839,7 +2858,6 @@ setup_environment (int argc,
2839 } 2858 }
2840 } 2859 }
2841 2860
2842 (*argc_out) = n;
2843 (*argv_free) = main_malloc(sizeof(char*) * (n + 1)); 2861 (*argv_free) = main_malloc(sizeof(char*) * (n + 1));
2844 (*argv_out) = (*argv_free); 2862 (*argv_out) = (*argv_free);
2845 (*argv_out)[0] = argv[0]; 2863 (*argv_out)[0] = argv[0];
@@ -2851,7 +2869,7 @@ setup_environment (int argc,
2851 while (*p != ' ' && *p != 0) { 2869 while (*p != ' ' && *p != 0) {
2852 p++; 2870 p++;
2853 } 2871 }
2854 if (*p == ' ') { 2872 while (*p == ' ') {
2855 *p++ = 0; 2873 *p++ = 0;
2856 } 2874 }
2857 } 2875 }
@@ -2860,7 +2878,11 @@ setup_environment (int argc,
2860 (*argv_out)[i++] = argv[i0]; 2878 (*argv_out)[i++] = argv[i0];
2861 } 2879 }
2862 2880
2863 XD3_ASSERT (i == n); 2881 /* Counting spaces is an upper bound, argv stays NULL terminated. */
2882 (*argc_out) = i;
2883 while (i <= n) {
2884 (*argv_out)[i++] = NULL;
2885 }
2864} 2886}
2865 2887
2866int 2888int
@@ -2881,8 +2903,8 @@ main (int argc, char **argv)
2881 char *sfilename; 2903 char *sfilename;
2882 int env_argc; 2904 int env_argc;
2883 char **env_argv; 2905 char **env_argv;
2884 char **free_argv; /* malloced */ 2906 char **free_argv; /* malloc() in setup_environment() */
2885 char *free_value; /* malloced */ 2907 char *free_value; /* malloc() in setup_environment() */
2886 int ret; 2908 int ret;
2887 2909
2888#ifdef _WIN32 2910#ifdef _WIN32
@@ -3248,7 +3270,7 @@ main (int argc, char **argv)
3248static int 3270static int
3249main_help (void) 3271main_help (void)
3250{ 3272{
3251 /* TODO: update www/xdelta3-cmdline.html */ 3273 /* Note: update wiki when command-line features change */
3252 main_version (); 3274 main_version ();
3253 P(RINT "usage: xdelta3 [command/options] [input [output]]\n"); 3275 P(RINT "usage: xdelta3 [command/options] [input [output]]\n");
3254 P(RINT "special command names:\n"); 3276 P(RINT "special command names:\n");
@@ -3296,5 +3318,9 @@ main_help (void)
3296 P(RINT " -P repeat count (for profiling)\n"); 3318 P(RINT " -P repeat count (for profiling)\n");
3297 P(RINT " -T use alternate code table\n"); 3319 P(RINT " -T use alternate code table\n");
3298#endif 3320#endif
3321 P(RINT "the XDELTA environment variable may contain extra args:\n");
3322 P(RINT " XDELTA=\"-s source-x.y.tar.gz\" \\\n");
3323 P(RINT " tar --use-compress-program=xdelta3 \\\n");
3324 P(RINT " -cf target-x.z.tar.gz.vcdiff target-x.y/\n");
3299 return EXIT_FAILURE; 3325 return EXIT_FAILURE;
3300} 3326}