second set of ANSI C changes: C89-style function declarations, more inline functions, remove register keyword

This commit is contained in:
Chet Ramey
2023-01-03 10:23:11 -05:00
parent 81e3a4fb07
commit a61ffa78ed
85 changed files with 2867 additions and 5479 deletions
+10 -33
View File
@@ -1,6 +1,6 @@
/* stringlib.c - Miscellaneous string functions. */
/* Copyright (C) 1996-2009 Free Software Foundation, Inc.
/* Copyright (C) 1996-2009,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -48,10 +48,7 @@
/* Find STRING in ALIST, a list of string key/int value pairs. If FLAGS
is 1, STRING is treated as a pattern and matched using strmatch. */
int
find_string_in_alist (string, alist, flags)
char *string;
STRING_INT_ALIST *alist;
int flags;
find_string_in_alist (char *string, STRING_INT_ALIST *alist, int flags)
{
register int i;
int r;
@@ -75,10 +72,7 @@ find_string_in_alist (string, alist, flags)
corresponding string. Allocates memory for the returned
string. FLAGS is currently ignored, but reserved. */
char *
find_token_in_alist (token, alist, flags)
int token;
STRING_INT_ALIST *alist;
int flags;
find_token_in_alist (int token, STRING_INT_ALIST *alist, int flags)
{
register int i;
@@ -91,10 +85,7 @@ find_token_in_alist (token, alist, flags)
}
int
find_index_in_alist (string, alist, flags)
char *string;
STRING_INT_ALIST *alist;
int flags;
find_index_in_alist (char *string, STRING_INT_ALIST *alist, int flags)
{
register int i;
int r;
@@ -124,9 +115,7 @@ find_index_in_alist (string, alist, flags)
/* Cons a new string from STRING starting at START and ending at END,
not including END. */
char *
substring (string, start, end)
const char *string;
int start, end;
substring (const char *string, int start, int end)
{
register int len;
register char *result;
@@ -142,9 +131,7 @@ substring (string, start, end)
replace all occurrences, otherwise replace only the first.
This returns a new string; the caller should free it. */
char *
strsub (string, pat, rep, global)
char *string, *pat, *rep;
int global;
strsub (char *string, char *pat, char *rep, int global)
{
size_t patlen, replen, templen, tempsize, i;
int repl;
@@ -183,11 +170,7 @@ strsub (string, pat, rep, global)
globbing. Backslash may be used to quote C. If (FLAGS & 2) we allow
backslash to escape backslash as well. */
char *
strcreplace (string, c, text, flags)
char *string;
int c;
const char *text;
int flags;
strcreplace (char *string, int c, const char *text, int flags)
{
char *ret, *p, *r, *t;
size_t len, rlen, ind, tlen;
@@ -248,8 +231,7 @@ strcreplace (string, c, text, flags)
/* Remove all leading whitespace from STRING. This includes
newlines. STRING should be terminated with a zero. */
void
strip_leading (string)
char *string;
strip_leading (char *string)
{
char *start = string;
@@ -269,10 +251,7 @@ strip_leading (string)
newlines. If NEWLINES_ONLY is non-zero, only trailing newlines
are removed. STRING should be terminated with a zero. */
void
strip_trailing (string, len, newlines_only)
char *string;
int len;
int newlines_only;
strip_trailing (char *string, int len, int newlines_only)
{
while (len >= 0)
{
@@ -287,9 +266,7 @@ strip_trailing (string, len, newlines_only)
/* A wrapper for bcopy that can be prototyped in general.h */
void
xbcopy (s, d, n)
char *s, *d;
int n;
xbcopy (char *s, char *d, size_t n)
{
FASTCOPY (s, d, n);
}