mirror of
https://github.com/yann64/haikuports.git
synced 2026-05-07 07:28:57 +02:00
186 lines
6.5 KiB
Plaintext
186 lines
6.5 KiB
Plaintext
From 8158628bb0ec27f5a44000efbe08be00a4f63aea Mon Sep 17 00:00:00 2001
|
|
From: fbrosson <fbrosson@localhost>
|
|
Date: Sat, 16 Jun 2018 21:07:34 +0000
|
|
Subject: C89 fixes for gcc2 compatibility
|
|
|
|
|
|
diff --git a/lib/glob.c b/lib/glob.c
|
|
index a5e4e93..d9c7c0f 100644
|
|
--- a/lib/glob.c
|
|
+++ b/lib/glob.c
|
|
@@ -141,8 +141,11 @@ convert_dirent (const struct dirent *source)
|
|
struct readdir_result result = { NULL, };
|
|
return result;
|
|
}
|
|
+ else
|
|
+ {
|
|
struct readdir_result result = READDIR_RESULT_INITIALIZER (source);
|
|
return result;
|
|
+ }
|
|
}
|
|
|
|
#ifndef COMPILE_GLOB64
|
|
@@ -497,6 +500,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
|
|
else
|
|
{
|
|
char *newp;
|
|
+ bool drive_root;
|
|
dirlen = filename - pattern;
|
|
|
|
#if defined __MSDOS__ || defined WINDOWS32
|
|
@@ -532,18 +536,19 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
|
|
++filename;
|
|
|
|
#if defined __MSDOS__ || defined WINDOWS32
|
|
- bool drive_root = (dirlen > 1
|
|
+ drive_root = (dirlen > 1
|
|
&& (dirname[dirlen - 1] == ':'
|
|
|| (dirlen > 2 && dirname[dirlen - 2] == ':'
|
|
&& dirname[dirlen - 1] == '/')));
|
|
#else
|
|
- bool drive_root = false;
|
|
+ drive_root = false;
|
|
#endif
|
|
|
|
if (filename[0] == '\0' && dirlen > 1 && !drive_root)
|
|
/* "pattern/". Expand "pattern", appending slashes. */
|
|
{
|
|
int orig_flags = flags;
|
|
+ int val;
|
|
if (!(flags & GLOB_NOESCAPE) && dirname[dirlen - 1] == '\\')
|
|
{
|
|
/* "pattern\\/". Remove the final backslash if it hasn't
|
|
@@ -557,7 +562,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
|
|
flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC);
|
|
}
|
|
}
|
|
- int val = glob (dirname, flags | GLOB_MARK, errfunc, pglob);
|
|
+ val = glob (dirname, flags | GLOB_MARK, errfunc, pglob);
|
|
if (val == 0)
|
|
pglob->gl_flags = ((pglob->gl_flags & ~GLOB_MARK)
|
|
| (flags & GLOB_MARK));
|
|
@@ -775,12 +780,11 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
|
|
/* Look up specific user's home directory. */
|
|
{
|
|
struct passwd *p;
|
|
+ struct passwd pwbuf;
|
|
struct scratch_buffer pwtmpbuf;
|
|
scratch_buffer_init (&pwtmpbuf);
|
|
|
|
# if defined HAVE_GETPWNAM_R || defined _LIBC
|
|
- struct passwd pwbuf;
|
|
-
|
|
while (getpwnam_r (user_name, &pwbuf,
|
|
pwtmpbuf.data, pwtmpbuf.length, &p)
|
|
== ERANGE)
|
|
@@ -1400,7 +1404,8 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
|
|
while (1)
|
|
{
|
|
struct globnames *old = names;
|
|
- for (size_t i = 0; i < cur; ++i)
|
|
+ size_t i;
|
|
+ for (i = 0; i < cur; ++i)
|
|
free (names->name[i]);
|
|
names = names->next;
|
|
/* NB: we will not leak memory here if we exit without
|
|
@@ -1425,7 +1430,8 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
|
|
while (1)
|
|
{
|
|
struct globnames *old = names;
|
|
- for (size_t i = 0; i < cur; ++i)
|
|
+ size_t i;
|
|
+ for (i = 0; i < cur; ++i)
|
|
new_gl_pathv[pglob->gl_offs + pglob->gl_pathc++]
|
|
= names->name[i];
|
|
names = names->next;
|
|
diff --git a/lib/malloc/scratch_buffer_set_array_size.c b/lib/malloc/scratch_buffer_set_array_size.c
|
|
index 4e43e7c..2cef316 100644
|
|
--- a/lib/malloc/scratch_buffer_set_array_size.c
|
|
+++ b/lib/malloc/scratch_buffer_set_array_size.c
|
|
@@ -29,6 +29,7 @@ __libc_scratch_buffer_set_array_size (struct scratch_buffer *buffer,
|
|
size_t nelem, size_t size)
|
|
{
|
|
size_t new_length = nelem * size;
|
|
+ char *new_ptr;
|
|
|
|
/* Avoid overflow check if both values are small. */
|
|
if ((nelem | size) >> (sizeof (size_t) * CHAR_BIT / 2) != 0
|
|
@@ -48,7 +49,7 @@ __libc_scratch_buffer_set_array_size (struct scratch_buffer *buffer,
|
|
/* Discard old buffer. */
|
|
scratch_buffer_free (buffer);
|
|
|
|
- char *new_ptr = malloc (new_length);
|
|
+ new_ptr = malloc (new_length);
|
|
if (new_ptr == NULL)
|
|
{
|
|
/* Buffer must remain valid to free. */
|
|
diff --git a/src/browser.c b/src/browser.c
|
|
index 1213361..ce3df39 100644
|
|
--- a/src/browser.c
|
|
+++ b/src/browser.c
|
|
@@ -224,6 +224,7 @@ char *do_browser(char *path)
|
|
} else if (func == to_last_file) {
|
|
selected = filelist_len - 1;
|
|
} else if (func == goto_dir_void) {
|
|
+ size_t j;
|
|
/* Ask for the directory to go to. */
|
|
int i = do_prompt(TRUE, FALSE, MGOTODIR, NULL, NULL,
|
|
/* TRANSLATORS: This is a prompt. */
|
|
@@ -258,7 +259,7 @@ char *do_browser(char *path)
|
|
|
|
/* In case the specified directory cannot be entered, select it
|
|
* (if it is in the current list) so it will be highlighted. */
|
|
- for (size_t j = 0; j < filelist_len; j++)
|
|
+ for (j = 0; j < filelist_len; j++)
|
|
if (strcmp(filelist[j], path) == 0)
|
|
selected = j;
|
|
|
|
diff --git a/src/global.c b/src/global.c
|
|
index fc5fad3..2bf3aa5 100644
|
|
--- a/src/global.c
|
|
+++ b/src/global.c
|
|
@@ -1374,7 +1374,8 @@ void shortcut_init(void)
|
|
/* Assign one function's shortcuts to another function. */
|
|
void replace_scs_for(void (*oldfunc)(void), void (*newfunc)(void))
|
|
{
|
|
- for (sc *s = sclist; s != NULL; s = s->next)
|
|
+ sc *s;
|
|
+ for (s = sclist; s != NULL; s = s->next)
|
|
if (s->func == oldfunc)
|
|
s->func = newfunc;
|
|
}
|
|
diff --git a/src/winio.c b/src/winio.c
|
|
index 281488a..686df45 100644
|
|
--- a/src/winio.c
|
|
+++ b/src/winio.c
|
|
@@ -290,7 +290,8 @@ void unget_kbinput(int kbinput, bool metakey)
|
|
/* Insert the given string into the keyboard buffer. */
|
|
void implant(const char *string)
|
|
{
|
|
- for (int i = strlen(string); i > 0; i--)
|
|
+ int i;
|
|
+ for (i = strlen(string); i > 0; i--)
|
|
put_back(string[i - 1]);
|
|
}
|
|
#endif
|
|
@@ -1267,6 +1268,7 @@ int arrow_from_abcd(int kbinput)
|
|
int parse_escape_sequence(WINDOW *win, int kbinput)
|
|
{
|
|
int retval, *sequence, length, consumed;
|
|
+ int i;
|
|
|
|
/* Put back the non-escape code, then grab at most five integers
|
|
* (the longest possible escape sequence) from the keybuffer and
|
|
@@ -1277,7 +1279,7 @@ int parse_escape_sequence(WINDOW *win, int kbinput)
|
|
retval = convert_sequence(sequence, length, &consumed);
|
|
|
|
/* If not all grabbed integers were consumed, put the leftovers back. */
|
|
- for (int i = length - 1; i >= consumed; i--)
|
|
+ for (i = length - 1; i >= consumed; i--)
|
|
put_back(sequence[i]);
|
|
|
|
free(sequence);
|
|
--
|
|
2.17.1
|
|
|