1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Sfio: fix non-multibyte build (re: 7c4418cc)

The Sfio code uses its own _has_multibyte macro and that was not
being disabled by AST_NOMULTIBYTE, so some of its multibyte code
was still getting compiled in. This is easily fixed in sfhdr.h.

But that exposed another issue: the Sfio stdio wrappers didn't
know about the _has_multibyte macro. So this adds the necessary
directives to keep their multibyte functions from compiling.
This commit is contained in:
Martijn Dekker 2022-07-27 16:56:54 +02:00
parent ca5ea73d8c
commit eea3ca3fd1
23 changed files with 190 additions and 12 deletions

View file

@ -180,7 +180,9 @@
#include <ctype.h> #include <ctype.h>
/* deal with multi-byte character and string conversions */ /* deal with multi-byte character and string conversions */
#if _PACKAGE_ast #if AST_NOMULTIBYTE
#undef _has_multibyte
#elif _PACKAGE_ast
#include <wchar.h> #include <wchar.h>

View file

@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(fgetwc)
#else
wint_t wint_t
fgetwc(Sfio_t* f) fgetwc(Sfio_t* f)
{ {
@ -31,3 +37,5 @@ fgetwc(Sfio_t* f)
FWIDE(f, WEOF); FWIDE(f, WEOF);
return (sfread(f, &c, sizeof(c)) == sizeof(c)) ? c : WEOF; return (sfread(f, &c, sizeof(c)) == sizeof(c)) ? c : WEOF;
} }
#endif /* !_has_multibyte */

View file

@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(fgetws)
#else
wchar_t* wchar_t*
fgetws(wchar_t* s, int n, Sfio_t* f) fgetws(wchar_t* s, int n, Sfio_t* f)
{ {
@ -48,3 +54,5 @@ getws(wchar_t* s)
*p = 0; *p = 0;
return s; return s;
} }
#endif /* !_has_multibyte */

View file

@ -23,9 +23,17 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(fputwc)
#else
wint_t wint_t
fputwc(wchar_t c, Sfio_t* f) fputwc(wchar_t c, Sfio_t* f)
{ {
FWIDE(f, WEOF); FWIDE(f, WEOF);
return (sfwrite(f, &c, sizeof(c)) == sizeof(c)) ? c : WEOF; return (sfwrite(f, &c, sizeof(c)) == sizeof(c)) ? c : WEOF;
} }
#endif /* !_has_multibyte */

View file

@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(fputws)
#else
int int
fputws(const wchar_t* s, Sfio_t* f) fputws(const wchar_t* s, Sfio_t* f)
{ {
@ -32,3 +38,5 @@ fputws(const wchar_t* s, Sfio_t* f)
n = wcslen(s) * sizeof(wchar_t); n = wcslen(s) * sizeof(wchar_t);
return (sfwrite(f, s, n) == n) ? 0 : -1; return (sfwrite(f, s, n) == n) ? 0 : -1;
} }
#endif /* !_has_multibyte */

View file

@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(fwide)
#else
int int
fwide(Sfio_t* f, int mode) fwide(Sfio_t* f, int mode)
{ {
@ -47,3 +53,5 @@ fwide(Sfio_t* f, int mode)
} }
return 0; return 0;
} }
#endif /* !_has_multibyte */

View file

@ -2,7 +2,7 @@
* * * *
* This software is part of the ast package * * This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property * * Copyright (c) 1985-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m * * Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the * * and is licensed under the *
* Eclipse Public License, Version 1.0 * * Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property * * by AT&T Intellectual Property *
@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(fwprintf)
#else
int int
fwprintf(Sfio_t* f, const wchar_t* fmt, ...) fwprintf(Sfio_t* f, const wchar_t* fmt, ...)
{ {
@ -34,3 +40,5 @@ fwprintf(Sfio_t* f, const wchar_t* fmt, ...)
va_end(args); va_end(args);
return v; return v;
} }
#endif /* !_has_multibyte */

View file

@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(fwscanf)
#else
int int
fwscanf(Sfio_t* f, const wchar_t* fmt, ...) fwscanf(Sfio_t* f, const wchar_t* fmt, ...)
{ {
@ -35,3 +41,5 @@ fwscanf(Sfio_t* f, const wchar_t* fmt, ...)
va_end(args); va_end(args);
return v; return v;
} }
#endif /* !_has_multibyte */

View file

@ -2,7 +2,7 @@
* * * *
* This software is part of the ast package * * This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property * * Copyright (c) 1985-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m * * Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the * * and is licensed under the *
* Eclipse Public License, Version 1.0 * * Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property * * by AT&T Intellectual Property *
@ -24,8 +24,16 @@
#include "stdhdr.h" #include "stdhdr.h"
#include "ast_wchar.h" #include "ast_wchar.h"
#if !_has_multibyte
NoN(getwc)
#else
wint_t wint_t
getwc(Sfio_t* f) getwc(Sfio_t* f)
{ {
return fgetwc(f); return fgetwc(f);
} }
#endif /* !_has_multibyte */

View file

@ -2,7 +2,7 @@
* * * *
* This software is part of the ast package * * This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property * * Copyright (c) 1985-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m * * Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the * * and is licensed under the *
* Eclipse Public License, Version 1.0 * * Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property * * by AT&T Intellectual Property *
@ -24,8 +24,16 @@
#include "stdhdr.h" #include "stdhdr.h"
#include "ast_wchar.h" #include "ast_wchar.h"
#if !_has_multibyte
NoN(getwchar)
#else
wint_t wint_t
getwchar(void) getwchar(void)
{ {
return fgetwc(sfstdin); return fgetwc(sfstdin);
} }
#endif /* !_has_multibyte */

View file

@ -2,7 +2,7 @@
* * * *
* This software is part of the ast package * * This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property * * Copyright (c) 1985-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m * * Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the * * and is licensed under the *
* Eclipse Public License, Version 1.0 * * Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property * * by AT&T Intellectual Property *
@ -24,8 +24,16 @@
#include "stdhdr.h" #include "stdhdr.h"
#include "ast_wchar.h" #include "ast_wchar.h"
#if !_has_multibyte
NoN(putwc)
#else
wint_t wint_t
putwc(wchar_t c, Sfio_t* f) putwc(wchar_t c, Sfio_t* f)
{ {
return fputwc(c, f); return fputwc(c, f);
} }
#endif /* !_has_multibyte */

View file

@ -2,7 +2,7 @@
* * * *
* This software is part of the ast package * * This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property * * Copyright (c) 1985-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m * * Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the * * and is licensed under the *
* Eclipse Public License, Version 1.0 * * Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property * * by AT&T Intellectual Property *
@ -24,8 +24,16 @@
#include "stdhdr.h" #include "stdhdr.h"
#include "ast_wchar.h" #include "ast_wchar.h"
#if !_has_multibyte
NoN(putwchar)
#else
wint_t wint_t
putwchar(wchar_t c) putwchar(wchar_t c)
{ {
return fputwc(c, sfstdout); return fputwc(c, sfstdout);
} }
#endif /* !_has_multibyte */

View file

@ -2,7 +2,7 @@
* * * *
* This software is part of the ast package * * This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property * * Copyright (c) 1985-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m * * Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the * * and is licensed under the *
* Eclipse Public License, Version 1.0 * * Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property * * by AT&T Intellectual Property *
@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(swprintf)
#else
int int
swprintf(wchar_t* s, size_t size, const wchar_t* fmt, ...) swprintf(wchar_t* s, size_t size, const wchar_t* fmt, ...)
{ {
@ -34,3 +40,5 @@ swprintf(wchar_t* s, size_t size, const wchar_t* fmt, ...)
va_end(args); va_end(args);
return v; return v;
} }
#endif /* !_has_multibyte */

View file

@ -2,7 +2,7 @@
* * * *
* This software is part of the ast package * * This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property * * Copyright (c) 1985-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m * * Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the * * and is licensed under the *
* Eclipse Public License, Version 1.0 * * Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property * * by AT&T Intellectual Property *
@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(swscanf)
#else
int int
swscanf(const wchar_t* s, const wchar_t* fmt, ...) swscanf(const wchar_t* s, const wchar_t* fmt, ...)
{ {
@ -34,3 +40,5 @@ swscanf(const wchar_t* s, const wchar_t* fmt, ...)
va_end(args); va_end(args);
return v; return v;
} }
#endif /* !_has_multibyte */

View file

@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(ungetwc)
#else
wint_t wint_t
ungetwc(wint_t c, Sfio_t* f) ungetwc(wint_t c, Sfio_t* f)
{ {
@ -35,3 +41,5 @@ ungetwc(wint_t c, Sfio_t* f)
return WEOF; return WEOF;
return c; return c;
} }
#endif /* !_has_multibyte */

View file

@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(vfwprintf)
#else
int int
vfwprintf(Sfio_t* f, const wchar_t* fmt, va_list args) vfwprintf(Sfio_t* f, const wchar_t* fmt, va_list args)
{ {
@ -64,3 +70,5 @@ vfwprintf(Sfio_t* f, const wchar_t* fmt, va_list args)
v = -1; v = -1;
return v; return v;
} }
#endif /* !_has_multibyte */

View file

@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(vfwscanf)
#else
typedef struct typedef struct
{ {
Sfdisc_t sfdisc; /* sfio discipline */ Sfdisc_t sfdisc; /* sfio discipline */
@ -117,3 +123,5 @@ vfwscanf(Sfio_t* f, const wchar_t* fmt, va_list args)
v = -1; v = -1;
return v; return v;
} }
#endif /* !_has_multibyte */

View file

@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(vswprintf)
#else
int int
vswprintf(wchar_t* s, size_t n, const wchar_t* fmt, va_list args) vswprintf(wchar_t* s, size_t n, const wchar_t* fmt, va_list args)
{ {
@ -53,3 +59,5 @@ vswprintf(wchar_t* s, size_t n, const wchar_t* fmt, va_list args)
_Sfi = f.next - f.data; _Sfi = f.next - f.data;
return v; return v;
} }
#endif /* !_has_multibyte */

View file

@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(vswscanf)
#else
int int
vswscanf(const wchar_t* s, const wchar_t* fmt, va_list args) vswscanf(const wchar_t* s, const wchar_t* fmt, va_list args)
{ {
@ -49,3 +55,5 @@ vswscanf(const wchar_t* s, const wchar_t* fmt, va_list args)
return vfwscanf(&f, fmt, args); return vfwscanf(&f, fmt, args);
} }
#endif /* !_has_multibyte */

View file

@ -2,7 +2,7 @@
* * * *
* This software is part of the ast package * * This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property * * Copyright (c) 1985-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m * * Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the * * and is licensed under the *
* Eclipse Public License, Version 1.0 * * Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property * * by AT&T Intellectual Property *
@ -23,8 +23,16 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(vwprintf)
#else
int int
vwprintf(const wchar_t* fmt, va_list args) vwprintf(const wchar_t* fmt, va_list args)
{ {
return vfwprintf(sfstdout, fmt, args); return vfwprintf(sfstdout, fmt, args);
} }
#endif /* !_has_multibyte */

View file

@ -2,7 +2,7 @@
* * * *
* This software is part of the ast package * * This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property * * Copyright (c) 1985-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m * * Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the * * and is licensed under the *
* Eclipse Public License, Version 1.0 * * Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property * * by AT&T Intellectual Property *
@ -23,8 +23,16 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(vwscanf)
#else
int int
vwscanf(const wchar_t* fmt, va_list args) vwscanf(const wchar_t* fmt, va_list args)
{ {
return vfwscanf(sfstdin, fmt, args); return vfwscanf(sfstdin, fmt, args);
} }
#endif /* !_has_multibyte */

View file

@ -2,7 +2,7 @@
* * * *
* This software is part of the ast package * * This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property * * Copyright (c) 1985-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m * * Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the * * and is licensed under the *
* Eclipse Public License, Version 1.0 * * Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property * * by AT&T Intellectual Property *
@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(wprintf)
#else
int int
wprintf(const wchar_t* fmt, ...) wprintf(const wchar_t* fmt, ...)
{ {
@ -34,3 +40,5 @@ wprintf(const wchar_t* fmt, ...)
va_end(args); va_end(args);
return v; return v;
} }
#endif /* !_has_multibyte */

View file

@ -2,7 +2,7 @@
* * * *
* This software is part of the ast package * * This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property * * Copyright (c) 1985-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m * * Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the * * and is licensed under the *
* Eclipse Public License, Version 1.0 * * Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property * * by AT&T Intellectual Property *
@ -23,6 +23,12 @@
#include "stdhdr.h" #include "stdhdr.h"
#if !_has_multibyte
NoN(wscanf)
#else
int int
wscanf(const wchar_t* fmt, ...) wscanf(const wchar_t* fmt, ...)
{ {
@ -34,3 +40,5 @@ wscanf(const wchar_t* fmt, ...)
va_end(args); va_end(args);
return v; return v;
} }
#endif /* !_has_multibyte */