Skip to content

Commit 929ffac

Browse files
committed
Fix gensub warning from newer gawk
- Use an explicit 1 for the third gensub argument ('how' param) when a single substitution is wanted. Prior to this change I used an empty string when I wanted a single substitution, but now gawk issues a warning for that. Fixes jay#1
1 parent 200da9a commit 929ffac

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

showlinenum.awk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ function get_bool( input, default_value )
215215
}
216216

217217
regex = "^[[:blank:]]*([0-1])[[:blank:]]*$";
218-
return ( ( input ~ regex ) ? gensub( regex, "\\1", "", input ) : default_value ) + 0;
218+
return ( ( input ~ regex ) ? gensub( regex, "\\1", 1, input ) : default_value ) + 0;
219219
}
220220

221221
# this returns a string with the ansi color codes removed
@@ -270,7 +270,7 @@ function strip_ansi_color_codes( input )
270270
regex = "^@@ -[0-9]+(,[0-9]+)? \\+([0-9]+)(,[0-9]+)? @@.*$";
271271
if( stripped ~ regex )
272272
{
273-
line = gensub( regex, "\\2", "", stripped );
273+
line = gensub( regex, "\\2", 1, stripped );
274274
# Adding zero to line converts it from a string to an integer.
275275
# That only works when all color codes have been removed.
276276
line = line + 0;
@@ -334,7 +334,7 @@ function strip_ansi_color_codes( input )
334334
regex = "^\\-\\-\\- (\\042?a\\/.+)$";
335335
if( stripped ~ regex )
336336
{
337-
oldfile_path = gensub( regex, "\\1", "", stripped );
337+
oldfile_path = gensub( regex, "\\1", 1, stripped );
338338

339339
# Exit if there's a colon in the path. This is to keep parsing sane.
340340
if( !allow_colons_in_path && ( oldfile_path ~ /:/ ) )
@@ -360,7 +360,7 @@ function strip_ansi_color_codes( input )
360360
regex = "^\\+\\+\\+ (\\042?b\\/.+)$";
361361
if( stripped ~ regex )
362362
{
363-
path = gensub( regex, "\\1", "", stripped );
363+
path = gensub( regex, "\\1", 1, stripped );
364364

365365
# Exit if there's a colon in the path. This is to keep parsing sane.
366366
if( !allow_colons_in_path && ( path ~ /:/ ) )
@@ -386,7 +386,7 @@ function strip_ansi_color_codes( input )
386386
regex = "^Binary files (.*) differ$";
387387
if( stripped ~ regex )
388388
{
389-
path = gensub( regex, "\\1", "", stripped );
389+
path = gensub( regex, "\\1", 1, stripped );
390390

391391
found_path = 0;
392392
found_oldfile_path = 0;

0 commit comments

Comments
 (0)