diff options
author | Jim Meyering <meyering@redhat.com> | 2010-04-08 18:39:24 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2010-04-08 19:29:42 +0200 |
commit | 699bcc4bd8166abb6ee26a37d9e1189817741277 (patch) | |
tree | b57f4c9bc3bf24c6b565f78966dc20ff98a4c36a /lib | |
parent | e4f69c178ee9e68ecdbd743de669ec8c1388e40f (diff) | |
download | grep-699bcc4bd8166abb6ee26a37d9e1189817741277.tar.gz |
convert all TABs to equivalent spaces in indentation
Using this file,
cat > leading-blank.exempt <<\EOF
(?:^|\/)ChangeLog[^/]*$
(?:^|\/)(?:GNU)?[Mm]akefile[^/]*$
\.(?:am|mk)$
EOF
run this command to convert all non-conforming leading white
space to be all spaces:
git ls-files \
| pcregrep -vf leading-blank.exempt \
| xargs pcregrep -l '^ *\t' \
| xargs perl -MText::Tabs -ni -le \
'$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/savedir.c | 90 | ||||
-rw-r--r-- | lib/savedir.h | 4 |
2 files changed, 47 insertions, 47 deletions
diff --git a/lib/savedir.c b/lib/savedir.c index 6b2a848c..2d17f3f2 100644 --- a/lib/savedir.c +++ b/lib/savedir.c @@ -74,7 +74,7 @@ isdir1 (const char *dir, const char *file) Return NULL if DIR cannot be opened or if out of memory. */ char * savedir (const char *dir, off_t name_size, struct exclude *included_patterns, - struct exclude *excluded_patterns, struct exclude *excluded_directory_patterns ) + struct exclude *excluded_patterns, struct exclude *excluded_directory_patterns ) { DIR *dirp; struct dirent *dp; @@ -102,50 +102,50 @@ savedir (const char *dir, off_t name_size, struct exclude *included_patterns, { /* Skip "." and ".." (some NFS file systems' directories lack them). */ if (dp->d_name[0] != '.' - || (dp->d_name[1] != '\0' - && (dp->d_name[1] != '.' || dp->d_name[2] != '\0'))) - { - size_t namlen = strlen (dp->d_name); - size_t size_needed = (namep - name_space) + namlen + 2; - - if ((included_patterns || excluded_patterns) - && !isdir1 (dir, dp->d_name)) - { - if (included_patterns - && excluded_file_name (included_patterns, dp->d_name)) - continue; - if (excluded_patterns - && excluded_file_name (excluded_patterns, dp->d_name)) - continue; - } - - if ( excluded_directory_patterns - && isdir1 (dir, dp->d_name) ) - { - if (excluded_directory_patterns - && excluded_file_name (excluded_directory_patterns, dp->d_name)) - continue; - } - - if (size_needed > name_size) - { - char *new_name_space; - - while (size_needed > name_size) - name_size += 1024; - - new_name_space = realloc (name_space, name_size); - if (new_name_space == NULL) - { - closedir (dirp); - goto fail; - } - namep = new_name_space + (namep - name_space); - name_space = new_name_space; - } - strcpy (namep, dp->d_name); - namep += namlen + 1; - } + || (dp->d_name[1] != '\0' + && (dp->d_name[1] != '.' || dp->d_name[2] != '\0'))) + { + size_t namlen = strlen (dp->d_name); + size_t size_needed = (namep - name_space) + namlen + 2; + + if ((included_patterns || excluded_patterns) + && !isdir1 (dir, dp->d_name)) + { + if (included_patterns + && excluded_file_name (included_patterns, dp->d_name)) + continue; + if (excluded_patterns + && excluded_file_name (excluded_patterns, dp->d_name)) + continue; + } + + if ( excluded_directory_patterns + && isdir1 (dir, dp->d_name) ) + { + if (excluded_directory_patterns + && excluded_file_name (excluded_directory_patterns, dp->d_name)) + continue; + } + + if (size_needed > name_size) + { + char *new_name_space; + + while (size_needed > name_size) + name_size += 1024; + + new_name_space = realloc (name_space, name_size); + if (new_name_space == NULL) + { + closedir (dirp); + goto fail; + } + namep = new_name_space + (namep - name_space); + name_space = new_name_space; + } + strcpy (namep, dp->d_name); + namep += namlen + 1; + } } *namep = '\0'; if (CLOSEDIR (dirp)) diff --git a/lib/savedir.h b/lib/savedir.h index 003f7fe3..00cb1a98 100644 --- a/lib/savedir.h +++ b/lib/savedir.h @@ -5,7 +5,7 @@ extern char * savedir (const char *dir, off_t name_size, - struct exclude *, struct exclude *, - struct exclude *); + struct exclude *, struct exclude *, + struct exclude *); #endif |