mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-12 06:30:50 +02:00
second set of ANSI C changes: C89-style function declarations, more inline functions, remove register keyword
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* braces.c -- code for doing word expansion in curly braces. */
|
||||
|
||||
/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2020,2022 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -59,7 +59,7 @@ extern int errno;
|
||||
|
||||
#define BRACE_SEQ_SPECIFIER ".."
|
||||
|
||||
extern int asprintf PARAMS((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
|
||||
extern int asprintf (char **, const char *, ...) __attribute__((__format__ (printf, 2, 3)));
|
||||
|
||||
/* Basic idea:
|
||||
|
||||
@@ -73,19 +73,11 @@ extern int asprintf PARAMS((char **, const char *, ...)) __attribute__((__format
|
||||
/* The character which is used to separate arguments. */
|
||||
static const int brace_arg_separator = ',';
|
||||
|
||||
#if defined (PARAMS)
|
||||
static int brace_gobbler PARAMS((char *, size_t, int *, int));
|
||||
static char **expand_amble PARAMS((char *, size_t, int));
|
||||
static char **expand_seqterm PARAMS((char *, size_t));
|
||||
static char **mkseq PARAMS((intmax_t, intmax_t, intmax_t, int, int));
|
||||
static char **array_concat PARAMS((char **, char **));
|
||||
#else
|
||||
static int brace_gobbler ();
|
||||
static char **expand_amble ();
|
||||
static char **expand_seqterm ();
|
||||
static char **mkseq();
|
||||
static char **array_concat ();
|
||||
#endif
|
||||
static int brace_gobbler (char *, size_t, int *, int);
|
||||
static char **expand_amble (char *, size_t, int);
|
||||
static char **expand_seqterm (char *, size_t);
|
||||
static char **mkseq (intmax_t, intmax_t, intmax_t, int, int);
|
||||
static char **array_concat (char **, char **);
|
||||
|
||||
#if 0
|
||||
static void
|
||||
@@ -101,8 +93,7 @@ dump_result (a)
|
||||
|
||||
/* Return an array of strings; the brace expansion of TEXT. */
|
||||
char **
|
||||
brace_expand (text)
|
||||
char *text;
|
||||
brace_expand (char *text)
|
||||
{
|
||||
register int start;
|
||||
size_t tlen;
|
||||
@@ -282,10 +273,7 @@ add_tack:
|
||||
expand each slot which needs it, until there are no more slots which
|
||||
need it. */
|
||||
static char **
|
||||
expand_amble (text, tlen, flags)
|
||||
char *text;
|
||||
size_t tlen;
|
||||
int flags;
|
||||
expand_amble (char *text, size_t tlen, int flags)
|
||||
{
|
||||
char **result, **partial, **tresult;
|
||||
char *tem;
|
||||
@@ -357,9 +345,7 @@ expand_amble (text, tlen, flags)
|
||||
#define ST_ZINT 3
|
||||
|
||||
static char **
|
||||
mkseq (start, end, incr, type, width)
|
||||
intmax_t start, end, incr;
|
||||
int type, width;
|
||||
mkseq (intmax_t start, intmax_t end, intmax_t incr, int type, int width)
|
||||
{
|
||||
intmax_t n, prevn;
|
||||
int i, nelem;
|
||||
@@ -469,9 +455,7 @@ mkseq (start, end, incr, type, width)
|
||||
}
|
||||
|
||||
static char **
|
||||
expand_seqterm (text, tlen)
|
||||
char *text;
|
||||
size_t tlen;
|
||||
expand_seqterm (char *text, size_t tlen)
|
||||
{
|
||||
char *t, *lhs, *rhs;
|
||||
int lhs_t, rhs_t, lhs_l, rhs_l, width;
|
||||
@@ -591,11 +575,7 @@ expand_seqterm (text, tlen)
|
||||
an inner set of braces.
|
||||
*/
|
||||
static int
|
||||
brace_gobbler (text, tlen, indx, satisfy)
|
||||
char *text;
|
||||
size_t tlen;
|
||||
int *indx;
|
||||
int satisfy;
|
||||
brace_gobbler (char *text, size_t tlen, int *indx, int satisfy)
|
||||
{
|
||||
register int i, c, quoted, level, commas, pass_next;
|
||||
#if defined (SHELL)
|
||||
@@ -729,8 +709,7 @@ comsub:
|
||||
are free ()'ed. ARR1 can be NULL, in that case, a new version of ARR2
|
||||
is returned. */
|
||||
static char **
|
||||
array_concat (arr1, arr2)
|
||||
char **arr1, **arr2;
|
||||
array_concat (char **arr1, char **arr2)
|
||||
{
|
||||
register int i, j, len, len1, len2;
|
||||
register char **result;
|
||||
@@ -795,29 +774,25 @@ array_concat (arr1, arr2)
|
||||
#include <stdio.h>
|
||||
|
||||
void *
|
||||
xmalloc(n)
|
||||
size_t n;
|
||||
xmalloc(size_t n)
|
||||
{
|
||||
return (malloc (n));
|
||||
}
|
||||
|
||||
void *
|
||||
xrealloc(p, n)
|
||||
void *p;
|
||||
size_t n;
|
||||
xrealloc(void *p, size_t n)
|
||||
{
|
||||
return (realloc (p, n));
|
||||
}
|
||||
|
||||
int
|
||||
internal_error (format, arg1, arg2)
|
||||
char *format, *arg1, *arg2;
|
||||
internal_error (char *format, char *arg1, char *arg2)
|
||||
{
|
||||
fprintf (stderr, format, arg1, arg2);
|
||||
fprintf (stderr, "\n");
|
||||
}
|
||||
|
||||
main ()
|
||||
main (int c, char **v)
|
||||
{
|
||||
char example[256];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user