/****************************************************************************
- * Copyright (c) 1998-2001,2002 Free Software Foundation, Inc. *
+ * Copyright 2020,2023 Thomas E. Dickey *
+ * Copyright 1998-2004,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
#if !HAVE_VSSCANF
-MODULE_ID("$Id: vsscanf.c,v 1.16 2002/09/07 17:27:56 tom Exp $")
+MODULE_ID("$Id: vsscanf.c,v 1.22 2023/09/23 18:48:57 tom Exp $")
#if !(HAVE_VFSCANF || HAVE__DOSCAN)
#include <ctype.h>
-#define L_SQUARE '['
-#define R_SQUARE ']'
-
typedef enum {
cUnknown
,cError /* anything that isn't ANSI */
/* find a chunk */
state = sUnknown;
chunk = cUnknown;
- other = cUnknown;
+ other = oUnknown;
pointer = 0;
for (n = 0; format[n] != 0 && state != sFinal; ++n) {
my_fmt[n] = format[n];
case sPercent:
if (format[n] == '%') {
state = sUnknown;
- } else if (format[n] == L_SQUARE) {
+ } else if (format[n] == L_BLOCK) {
state = sLeft;
} else {
state = sNormal;
}
break;
case sRange:
- if (format[n] == R_SQUARE) {
+ if (format[n] == R_BLOCK) {
state = sFinal;
chunk = cRange;
}
chunk = ctest;
} else if ((otest = other_ch(format[n])) != oUnknown) {
other = otest;
- } else if (isalpha(format[n])) {
+ } else if (isalpha(UChar(format[n]))) {
state = sFinal;
chunk = cError;
}
/* add %n, if the format was not that */
if (chunk != cAssigned) {
- strcat(my_fmt, "%n");
+ _nc_STRCAT(my_fmt, "%n", len_fmt);
}
switch (chunk) {
case cAssigned:
- strcat(my_fmt, "%n");
+ _nc_STRCAT(my_fmt, "%n", len_fmt);
pointer = &eaten;
break;
case cInt: