Fri Mar 13 16:43:05 2020 UTC ()
pkgtools/check-portability: elimitate common subexpression


(rillig)
diff -r1.8 -r1.9 pkgsrc/pkgtools/check-portability/files/check-portability.c

cvs diff -r1.8 -r1.9 pkgsrc/pkgtools/check-portability/files/check-portability.c (expand / switch to unified diff)

--- pkgsrc/pkgtools/check-portability/files/check-portability.c 2020/03/13 16:20:34 1.8
+++ pkgsrc/pkgtools/check-portability/files/check-portability.c 2020/03/13 16:43:05 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: check-portability.c,v 1.8 2020/03/13 16:20:34 rillig Exp $ */ 1/* $NetBSD: check-portability.c,v 1.9 2020/03/13 16:43:05 rillig Exp $ */
2 2
3/* 3/*
4 Copyright (c) 2020 Roland Illig 4 Copyright (c) 2020 Roland Illig
5 All rights reserved. 5 All rights reserved.
6 6
7 Redistribution and use in source and binary forms, with or without 7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions 8 modification, are permitted provided that the following conditions
9 are met: 9 are met:
10 10
11 1. Redistributions of source code must retain the above copyright 11 1. Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer. 12 notice, this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright 13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the 14 notice, this list of conditions and the following disclaimer in the
@@ -516,27 +516,27 @@ check_file(cstr filename) @@ -516,27 +516,27 @@ check_file(cstr filename)
516 str line = STR_EMPTY; 516 str line = STR_EMPTY;
517 517
518 size_t lineno = 0; 518 size_t lineno = 0;
519 if (!skip_shebang(basename)) { 519 if (!skip_shebang(basename)) {
520 if (!str_read_line(&line, f)) 520 if (!str_read_line(&line, f))
521 goto cleanup; 521 goto cleanup;
522 lineno++; 522 lineno++;
523 if (!is_shell_shebang(str_c(&line))) 523 if (!is_shell_shebang(str_c(&line)))
524 goto cleanup; 524 goto cleanup;
525 } 525 }
526 526
527 while (str_read_line(&line, f)) { 527 while (str_read_line(&line, f)) {
528 cstr cline = str_c(&line); 528 cstr cline = str_c(&line);
529 if (cstr_contains_char(str_c(&line), '\0')) 529 if (cstr_contains_char(cline, '\0'))
530 break; 530 break;
531 lineno++; 531 lineno++;
532 str_charptr(&line); 532 str_charptr(&line);
533 533
534 checkline_sh_double_brackets(filename, lineno, cline); 534 checkline_sh_double_brackets(filename, lineno, cline);
535 checkline_sh_dollar_random(filename, lineno, cline); 535 checkline_sh_dollar_random(filename, lineno, cline);
536 checkline_sh_test_eqeq(filename, lineno, cline); 536 checkline_sh_test_eqeq(filename, lineno, cline);
537 } 537 }
538 538
539cleanup: 539cleanup:
540 str_free(&line); 540 str_free(&line);
541 541
542 (void) fclose(f); 542 (void) fclose(f);