diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/cvs/src/diff.c | 2 | ||||
-rw-r--r-- | contrib/cvs/src/main.c | 37 | ||||
-rw-r--r-- | contrib/cvs/src/rcs.c | 2 |
3 files changed, 30 insertions, 11 deletions
diff --git a/contrib/cvs/src/diff.c b/contrib/cvs/src/diff.c index cc29f09..3fdf3e4 100644 --- a/contrib/cvs/src/diff.c +++ b/contrib/cvs/src/diff.c @@ -199,7 +199,7 @@ diff (argc, argv) } opts[0] = '\0'; - optind = 1; + optind = 0; while ((c = getopt_long (argc, argv, "+abcdefhilnpstuwy0123456789BHNRTC:D:F:I:L:U:V:W:k:r:", longopts, &option_index)) != -1) diff --git a/contrib/cvs/src/main.c b/contrib/cvs/src/main.c index bf8701a..dc0d1e8 100644 --- a/contrib/cvs/src/main.c +++ b/contrib/cvs/src/main.c @@ -331,6 +331,11 @@ main (argc, argv) const struct cmd *cm; int c, err = 0; int rcsbin_update_env, tmpdir_update_env, cvs_update_env; + int free_CVSroot = 0; + int free_Editor = 0; + int free_Tmpdir = 0; + int free_Rcsbin = 0; + int help = 0; /* Has the user asked for help? This lets us support the `cvs -H cmd' convention to give help for cmd. */ @@ -406,11 +411,9 @@ main (argc, argv) logoff = TRUE; } - /* I'm not sure whether this needs to be 1 instead of 0 anymore. Using - 1 used to accomplish what passing "+" as the first character to - the option string does, but that reason doesn't exist anymore. */ - optind = 1; - + /* Set this to 0 to force getopt initialization. getopt() sets + this to 1 internally. */ + optind = 0; /* We have to parse the options twice because else there is no chance to avoid reading the global options from ".cvsrc". Set @@ -432,7 +435,7 @@ main (argc, argv) if (use_cvsrc) read_cvsrc (&argc, &argv, "cvs"); - optind = 1; + optind = 0; opterr = 1; while ((c = getopt_long @@ -487,18 +490,22 @@ main (argc, argv) exit (0); break; case 'b': - Rcsbin = optarg; + Rcsbin = xstrdup (optarg); + free_Rcsbin = 1; rcsbin_update_env = 1; /* need to update environment */ break; case 'T': - Tmpdir = optarg; + Tmpdir = xstrdup (optarg); + free_Tmpdir = 1; tmpdir_update_env = 1; /* need to update environment */ break; case 'e': - Editor = optarg; + Editor = xstrdup (optarg); + free_Editor = 1; break; case 'd': - CVSroot = optarg; + CVSroot = xstrdup (optarg); + free_CVSroot = 1; cvs_update_env = 1; /* need to update environment */ break; case 'H': @@ -879,6 +886,16 @@ main (argc, argv) Lock_Cleanup (); + free (program_path); + if (free_CVSroot) + free (CVSroot); + if (free_Editor) + free (Editor); + if (free_Tmpdir) + free (Tmpdir); + if (free_Rcsbin) + free (Rcsbin); + #ifdef SYSTEM_CLEANUP /* Hook for OS-specific behavior, for example socket subsystems on NT and OS2 or dealing with windows and arguments on Mac. */ diff --git a/contrib/cvs/src/rcs.c b/contrib/cvs/src/rcs.c index ff4b47c..1187fb1 100644 --- a/contrib/cvs/src/rcs.c +++ b/contrib/cvs/src/rcs.c @@ -4068,6 +4068,8 @@ RCS_deltas (rcs, fp, version, op, text, len, log, loglen) break; } while (next != NULL); + free (branchversion); + if (fclose (fp) < 0) error (0, errno, "cannot close %s", rcs->path); |