Skip to content

Commit

Permalink
Fix export and remove strlcpy usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Girgias committed Aug 23, 2024
1 parent c1f3fcc commit f96ce00
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 4 additions & 4 deletions win32/glob.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#include "readdir.h"

#include <errno.h>
#include <string.h> /* For strcmp() */
#include <string.h>

#define DOLLAR '$'
#define DOT '.'
Expand Down Expand Up @@ -139,7 +139,7 @@ static bool match(Char *, Char *, Char *);
static void qprintf(const char *, Char *);
#endif

PW32IO int glob(const char *pattern, int flags, int (*errfunc)(const char *, int), glob_t *pglob)
PHP_WIN_GLOB int glob(const char *pattern, int flags, int (*errfunc)(const char *, int), glob_t *pglob)
{
const uint8_t *patnext;
int c;
Expand Down Expand Up @@ -726,7 +726,7 @@ static bool match(Char *name, Char *pat, Char *patend)
}

/* Free allocated data belonging to a glob_t structure. */
PW32IO void globfree(glob_t *pglob)
PHP_WIN_GLOB void globfree(glob_t *pglob)
{
register int i;
register char **pp;
Expand All @@ -746,7 +746,7 @@ static DIR * g_opendir(Char *str, glob_t *pglob)
char buf[MAXPATHLEN];

if (!*str)
strlcpy(buf, ".", sizeof(buf));
memcpy(buf, ".", strlen("."));
else {
if (g_Ctoc(str, buf, sizeof(buf)))
return(NULL);
Expand Down
11 changes: 8 additions & 3 deletions win32/glob.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@
#ifndef _GLOB_H_
#define _GLOB_H_

#ifdef PHP_EXPORTS
# define PHP_WIN_GLOB __declspec(dllexport)
#else
# define PHP_WIN_GLOB __declspec(dllimport)
#endif

#include <stddef.h>
#include "ioutil.h"

typedef struct {
size_t gl_pathc; /* Count of total paths so far. */
Expand Down Expand Up @@ -77,7 +82,7 @@ typedef struct {
#define GLOB_NOMATCH (-3) /* No match and GLOB_NOCHECK not set. */

BEGIN_EXTERN_C()
PW32IO int glob(const char *, int, int (*)(const char *, int), glob_t *);
PW32IO void globfree(glob_t *);
PHP_WIN_GLOB int glob(const char *, int, int (*)(const char *, int), glob_t *);
PHP_WIN_GLOB void globfree(glob_t *);
END_EXTERN_C()
#endif /* !_GLOB_H_ */

0 comments on commit f96ce00

Please sign in to comment.