X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Ftransform.c;h=349a0d59e21c7394781a9d27b44c7df8f2a907ff;hb=87ac3207fbc12e3f186f338b36012d1ee40e90c1;hp=23edd9ea631a302d7b7ec846b240a1f0bf1b407a;hpb=02c7b862a3068bfab33b724c5c226dc30a0a24e7;p=chaz%2Ftar diff --git a/src/transform.c b/src/transform.c index 23edd9e..349a0d5 100644 --- a/src/transform.c +++ b/src/transform.c @@ -1,9 +1,9 @@ /* This file is part of GNU tar. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006, 2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any later + Free Software Foundation; either version 3, or (at your option) any later version. This program is distributed in the hope that it will be useful, but @@ -19,7 +19,7 @@ #include #include "common.h" -enum transform_type +static enum transform_type { transform_none, transform_first, @@ -64,7 +64,7 @@ struct replace_segm /* Compiled replacement expression */ static struct replace_segm *repl_head, *repl_tail; -static segm_count; /* Number of elements in the above list */ +static size_t segm_count; /* Number of elements in the above list */ static struct replace_segm * add_segment (void) @@ -377,7 +377,6 @@ bool _transform_name_to_obstack (char *input) { regmatch_t *rmp; - char *p; int rc; size_t nmatches = 0; enum case_ctl_type case_ctl = ctl_stop, /* Current case conversion op */ @@ -499,21 +498,21 @@ _transform_name_to_obstack (char *input) } bool -transform_name_fp (char **pinput, char *(*fun)(char *)) +transform_name_fp (char **pinput, char *(*fun)(char *, void *), void *dat) { - char *str, *p; + char *str; bool ret = _transform_name_to_obstack (*pinput); if (ret) { str = obstack_finish (&stk); - assign_string (pinput, fun ? fun (str) : str); + assign_string (pinput, fun ? fun (str, dat) : str); obstack_free (&stk, str); } else if (fun) { str = *pinput; *pinput = NULL; - assign_string (pinput, fun (str)); + assign_string (pinput, fun (str, dat)); free (str); ret = true; } @@ -523,23 +522,6 @@ transform_name_fp (char **pinput, char *(*fun)(char *)) bool transform_name (char **pinput) { - return transform_name_fp (pinput, NULL); + return transform_name_fp (pinput, NULL, NULL); } -#if 0 -void -read_and_transform_loop () -{ - char buf[512]; - while (fgets (buf, sizeof buf, stdin)) - { - char *p = buf + strlen (buf); - if (p[-1] == '\n') - p[-1] = 0; - if (transform_name (buf, &p)) - printf ("=> %s\n", p); - else - printf ("=\n"); - } -} -#endif