diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2010-04-24 23:50:06 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2010-04-27 12:38:02 +0200 |
commit | de38f4acfb77c9d4ef728e9fd543b5e5a91cdd62 (patch) | |
tree | e4b93fb334a13c86eb7d5f06b7d7d1018a919d0e | |
parent | 3288f660a0cb59238ee07623a8b7d59512c39eab (diff) | |
download | patch-de38f4acfb77c9d4ef728e9fd543b5e5a91cdd62.tar.gz |
Do no declare local variables as "register" unnecessarily
* src/inp.c, src/patch.c, src/pch.c, src/util.c: Stop declaring
local variables as "register" all over the place: a decent compiler
will do a good enough job of place variables into registers where it
makes sense.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | src/inp.c | 32 | ||||
-rw-r--r-- | src/patch.c | 49 | ||||
-rw-r--r-- | src/pch.c | 76 | ||||
-rw-r--r-- | src/util.c | 10 |
5 files changed, 90 insertions, 84 deletions
@@ -1,3 +1,10 @@ +2009-04-24 Andreas Gruenbacher <agruen@suse.de> + + * src/inp.c, src/patch.c, src/pch.c, src/util.c: Stop declaring + local variables as "register" all over the place: a decent compiler + will do a good enough job of place variables into registers where it + makes sense. + 2009-04-23 Andreas Gruenbacher <agruen@suse.de> * patch.man: Describe the fixed behavior of --set-time and --set-utc @@ -211,11 +211,11 @@ get_input_file (char const *filename, char const *outname) static bool plan_a (char const *filename) { - register char const *s; - register char const *lim; - register char const **ptr; - register char *buffer; - register lin iline; + char const *s; + char const *lim; + char const **ptr; + char *buffer; + lin iline; size_t size = instat.st_size; /* Fail if the file size doesn't fit in a size_t, @@ -316,15 +316,15 @@ plan_a (char const *filename) static void plan_b (char const *filename) { - register FILE *ifp; - register int c; - register size_t len; - register size_t maxlen; - register bool found_revision; - register size_t i; - register char const *rev; - register size_t revlen; - register lin line = 1; + FILE *ifp; + int c; + size_t len; + size_t maxlen; + bool found_revision; + size_t i; + char const *rev; + size_t revlen; + lin line = 1; int exclusive; if (instat.st_size == 0) @@ -423,8 +423,8 @@ plan_b (char const *filename) char const * ifetch (lin line, bool whichbuf, size_t *psize) { - register char const *q; - register char const *p; + char const *q; + char const *p; if (line < 1 || line > input_lines) { *psize = 0; diff --git a/src/patch.c b/src/patch.c index d403d12..e310c6c 100644 --- a/src/patch.c +++ b/src/patch.c @@ -679,7 +679,7 @@ usage (FILE *stream, int status) static void get_some_switches (void) { - register int optc; + int optc; if (rejname) free (rejname); @@ -926,8 +926,8 @@ numeric_string (char const *string, static lin locate_hunk (lin fuzz) { - register lin first_guess = pch_first () + in_offset; - register lin offset; + lin first_guess = pch_first () + in_offset; + lin offset; lin pat_lines = pch_ptrn_lines(); lin prefix_context = pch_prefix_context (); lin suffix_context = pch_suffix_context (); @@ -1068,9 +1068,9 @@ static void abort_hunk_unified (bool header, bool reverse) { FILE *fp = rejfp; - register lin old = 1; - register lin lastline = pch_ptrn_lines (); - register lin new = lastline + 1; + lin old = 1; + lin lastline = pch_ptrn_lines (); + lin new = lastline + 1; if (header) { @@ -1124,8 +1124,8 @@ abort_hunk_unified (bool header, bool reverse) static void abort_hunk_context (bool header, bool reverse) { - register lin i; - register lin pat_end = pch_end (); + lin i; + lin pat_end = pch_end (); /* add in out_offset to guess the same as the previous successful hunk */ lin oldfirst = pch_first() + out_offset; lin newfirst = pch_newfirst() + out_offset; @@ -1205,13 +1205,13 @@ abort_hunk (bool header, bool reverse) static bool apply_hunk (struct outstate *outstate, lin where) { - register lin old = 1; - register lin lastline = pch_ptrn_lines (); - register lin new = lastline+1; - register enum {OUTSIDE, IN_IFNDEF, IN_IFDEF, IN_ELSE} def_state = OUTSIDE; - register char const *R_do_defines = do_defines; - register lin pat_end = pch_end (); - register FILE *fp = outstate->ofp; + lin old = 1; + lin lastline = pch_ptrn_lines (); + lin new = lastline+1; + enum {OUTSIDE, IN_IFNDEF, IN_IFDEF, IN_ELSE} def_state = OUTSIDE; + char const *R_do_defines = do_defines; + lin pat_end = pch_end (); + FILE *fp = outstate->ofp; where--; while (pch_char(new) == '=' || pch_char(new) == '\n') @@ -1402,11 +1402,11 @@ init_reject (void) /* Copy input file to output, up to wherever hunk is to be applied. */ bool -copy_till (register struct outstate *outstate, register lin lastline) +copy_till (struct outstate *outstate, lin lastline) { - register lin R_last_frozen_line = last_frozen_line; - register FILE *fp = outstate->ofp; - register char const *s; + lin R_last_frozen_line = last_frozen_line; + FILE *fp = outstate->ofp; + char const *s; size_t size; if (R_last_frozen_line > lastline) @@ -1465,11 +1465,11 @@ spew_output (struct outstate *outstate, struct stat *st) static bool patch_match (lin base, lin offset, lin prefix_fuzz, lin suffix_fuzz) { - register lin pline = 1 + prefix_fuzz; - register lin iline; - register lin pat_lines = pch_ptrn_lines () - suffix_fuzz; + lin pline = 1 + prefix_fuzz; + lin iline; + lin pat_lines = pch_ptrn_lines () - suffix_fuzz; size_t size; - register char const *p; + char const *p; for (iline=base+offset+prefix_fuzz; pline <= pat_lines; pline++,iline++) { p = ifetch (iline, offset >= 0, &size); @@ -1489,8 +1489,7 @@ patch_match (lin base, lin offset, lin prefix_fuzz, lin suffix_fuzz) /* Do two lines match with canonicalized white space? */ bool -similar (register char const *a, register size_t alen, - register char const *b, register size_t blen) +similar (char const *a, size_t alen, char const *b, size_t blen) { /* Ignore presence or absence of trailing newlines. */ alen -= alen && a[alen - 1] == '\n'; @@ -314,18 +314,18 @@ there_is_another_patch (bool need_header) static enum diff intuit_diff_type (bool need_header) { - register file_offset this_line = 0; - register file_offset first_command_line = -1; + file_offset this_line = 0; + file_offset first_command_line = -1; char first_ed_command_letter = 0; lin fcl_line = 0; /* Pacify `gcc -W'. */ - register bool this_is_a_command = false; - register bool stars_this_line = false; + bool this_is_a_command = false; + bool stars_this_line = false; bool git_diff = false; enum nametype i; struct stat st[3]; int stat_errno[3]; int version_controlled[3]; - register enum diff retval; + enum diff retval; for (i = OLD; i <= INDEX; i++) if (p_name[i]) { @@ -352,12 +352,12 @@ intuit_diff_type (bool need_header) Fseek (pfp, p_base, SEEK_SET); p_input_line = p_bline - 1; for (;;) { - register char *s; - register char *t; - register file_offset previous_line = this_line; - register bool last_line_was_command = this_is_a_command; - register bool stars_last_line = stars_this_line; - register size_t indent = 0; + char *s; + char *t; + file_offset previous_line = this_line; + bool last_line_was_command = this_is_a_command; + bool stars_last_line = stars_this_line; + size_t indent = 0; char ed_command_letter; bool strip_trailing_cr; size_t chars_read; @@ -853,9 +853,9 @@ next_intuit_at (file_offset file_pos, lin file_line) static void skip_to (file_offset file_pos, lin file_line) { - register FILE *i = pfp; - register FILE *o = stdout; - register int c; + FILE *i = pfp; + FILE *o = stdout; + int c; assert(p_base <= file_pos); if ((verbosity == VERBOSE || !inname) && p_base < file_pos) { @@ -926,9 +926,9 @@ scan_linenum (char *s0, lin *linenum) int another_hunk (enum diff difftype, bool rev) { - register char *s; - register lin context = 0; - register size_t chars_read; + char *s; + lin context = 0; + size_t chars_read; char numbuf0[LINENUM_LENGTH_BOUND + 1]; char numbuf1[LINENUM_LENGTH_BOUND + 1]; char numbuf2[LINENUM_LENGTH_BOUND + 1]; @@ -955,12 +955,12 @@ another_hunk (enum diff difftype, bool rev) file_offset line_beginning = file_tell (pfp); /* file pos of the current line */ lin repl_beginning = 0; /* index of --- line */ - register lin fillcnt = 0; /* #lines of missing ptrn or repl */ - register lin fillsrc; /* index of first line to copy */ - register lin filldst; /* index of first missing line */ + lin fillcnt = 0; /* #lines of missing ptrn or repl */ + lin fillsrc; /* index of first line to copy */ + lin filldst; /* index of first missing line */ bool ptrn_spaces_eaten = false; /* ptrn was slightly misformed */ bool some_context = false; /* (perhaps internal) context seen */ - register bool repl_could_be_missing = true; + bool repl_could_be_missing = true; bool ptrn_missing = false; /* The pattern was missing. */ bool repl_missing = false; /* Likewise for replacement. */ file_offset repl_backtrack_position = 0; @@ -1360,8 +1360,8 @@ another_hunk (enum diff difftype, bool rev) } else if (difftype == UNI_DIFF) { file_offset line_beginning = file_tell (pfp); /* file pos of the current line */ - register lin fillsrc; /* index of old lines */ - register lin filldst; /* index of new lines */ + lin fillsrc; /* index of old lines */ + lin filldst; /* index of new lines */ char ch = '\0'; chars_read = get_line (); @@ -1518,7 +1518,7 @@ another_hunk (enum diff difftype, bool rev) } else { /* normal diff--fake it up */ char hunk_type; - register int i; + int i; lin min, max; file_offset line_beginning = file_tell (pfp); @@ -1686,11 +1686,11 @@ static size_t pget_line (size_t indent, int rfc934_nesting, bool strip_trailing_cr, bool pass_comments_through) { - register FILE *fp = pfp; - register int c; - register size_t i; - register char *b; - register size_t s; + FILE *fp = pfp; + int c; + size_t i; + char *b; + size_t s; do { @@ -1777,9 +1777,9 @@ pget_line (size_t indent, int rfc934_nesting, bool strip_trailing_cr, static bool incomplete_line (void) { - register FILE *fp = pfp; - register int c; - register file_offset line_beginning = file_tell (fp); + FILE *fp = pfp; + int c; + file_offset line_beginning = file_tell (fp); if (getc (fp) == '\\') { @@ -1803,10 +1803,10 @@ pch_swap (void) char **tp_line; /* the text of the hunk */ size_t *tp_len; /* length of each line */ char *tp_char; /* +, -, and ! */ - register lin i; - register lin n; + lin i; + lin n; bool blankline = false; - register char *s; + char *s; i = p_first; p_first = p_newfirst; @@ -2089,9 +2089,9 @@ do_ed_script (FILE *ofp) { static char const editor_program[] = EDITOR_PROGRAM; - register file_offset beginning_of_this_line; - register FILE *pipefp = 0; - register size_t chars_read; + file_offset beginning_of_this_line; + FILE *pipefp = 0; + size_t chars_read; if (! dry_run && ! skip_rest_of_patch) { int exclusive = TMPOUTNAME_needs_removal ? 0 : O_EXCL; @@ -619,9 +619,9 @@ version_get (char const *filename, char const *cs, bool exists, bool readonly, /* Allocate a unique area for a string. */ char * -savebuf (register char const *s, register size_t size) +savebuf (char const *s, size_t size) { - register char *rv; + char *rv; if (! size) return NULL; @@ -1052,10 +1052,10 @@ replace_slashes (char *filename) Ignore the last element of `filename'. */ static void -makedirs (register char *filename) +makedirs (char *filename) { - register char *f; - register char *flim = replace_slashes (filename); + char *f; + char *flim = replace_slashes (filename); if (flim) { |