cextern/cfitsio/lib/eval_y.c
/* Copy into FFRESULT an error message about the unexpected token
   FFCHAR while in state FFSTATE.  Return the number of bytes copied,
   including the terminating null byte.  If FFRESULT is null, do not
   copy anything; just return the number of bytes that would be
   copied.  As a special case, return 0 if an ordinary "syntax error"
   message will do.  Return FFSIZE_MAXIMUM if overflow occurs during
   size calculation.  */
Copy into FFRESULT an error message about the unexpected token
FFCHAR while in state FFSTATE.  Return the number of bytes copied,
including the terminating null byte.  If FFRESULT is null, do not
copy anything; just return the number of bytes that would be
copied.  As a special case, return 0 if an ordinary "syntax error"
message will do.  Return FFSIZE_MAXIMUM if overflow occurs during
size calculation.
Copy into FFRESULT an error message about the unexpected token FFCHAR while in state FFSTATE . Return the number of bytes copied including the terminating null byte . If FFRESULT is null do not copy anything ; just return the number of bytes that would be copied . As a special case return 0 if an ordinary " syntax error " message will do . Return FFSIZE_MAXIMUM if overflow occurs during size calculation .
static FFSIZE_T
ffsyntax_error (char *ffresult, int ffstate, int ffchar)
{
  int ffn = ffpact[ffstate];
  if (! (FFPACT_NINF < ffn && ffn <= FFLAST))
    return 0;
  else
    {
      int fftype = FFTRANSLATE (ffchar);
      FFSIZE_T ffsize0 = fftnamerr (0, fftname[fftype]);
      FFSIZE_T ffsize = ffsize0;
      FFSIZE_T ffsize1;
      int ffsize_overflow = 0;
      enum { FFERROR_VERBOSE_ARGS_MAXIMUM = 5 };
      char const *ffarg[FFERROR_VERBOSE_ARGS_MAXIMUM];
      int ffx;
# if 0
      FF_("syntax error, unexpected %s");
      FF_("syntax error, unexpected %s, expecting %s");
      FF_("syntax error, unexpected %s, expecting %s or %s");
      FF_("syntax error, unexpected %s, expecting %s or %s or %s");
      FF_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
# endif
      char *fffmt;
      char const *fff;
      static char const ffunexpected[] = "syntax error, unexpected %s";
      static char const ffexpecting[] = ", expecting %s";
      static char const ffor[] = " or %s";
      char ffformat[sizeof ffunexpected
		    + sizeof ffexpecting - 1
		    + ((FFERROR_VERBOSE_ARGS_MAXIMUM - 2)
		       * (sizeof ffor - 1))];
      char const *ffprefix = ffexpecting;
      int ffxbegin = ffn < 0 ? -ffn : 0;
      int ffchecklim = FFLAST - ffn + 1;
      int ffxend = ffchecklim < FFNTOKENS ? ffchecklim : FFNTOKENS;
      int ffcount = 1;
      ffarg[0] = fftname[fftype];
      fffmt = ffstpcpy (ffformat, ffunexpected);
      for (ffx = ffxbegin; ffx < ffxend; ++ffx)
	if (ffcheck[ffx + ffn] == ffx && ffx != FFTERROR)
	  {
	    if (ffcount == FFERROR_VERBOSE_ARGS_MAXIMUM)
	      {
		ffcount = 1;
		ffsize = ffsize0;
		ffformat[sizeof ffunexpected - 1] = '\0';
		break;
	      }
	    ffarg[ffcount++] = fftname[ffx];
	    ffsize1 = ffsize + fftnamerr (0, fftname[ffx]);
	    ffsize_overflow |= (ffsize1 < ffsize);
	    ffsize = ffsize1;
	    fffmt = ffstpcpy (fffmt, ffprefix);
	    ffprefix = ffor;
	  }
      fff = FF_(ffformat);
      ffsize1 = ffsize + ffstrlen (fff);
      ffsize_overflow |= (ffsize1 < ffsize);
      ffsize = ffsize1;
      if (ffsize_overflow)
	return FFSIZE_MAXIMUM;
      if (ffresult)
	{
	  char *ffp = ffresult;
	  int ffi = 0;
	  while ((*ffp = *fff) != '\0')
	    {
	      if (*ffp == '%' && fff[1] == 's' && ffi < ffcount)
		{
		  ffp += fftnamerr (ffp, ffarg[ffi++]);
		  fff += 2;
		}
	      else
		{
		  ffp++;
		  fff++;
		}
	    }
	}
      return ffsize;
    }
}
static FFSIZE_T ffsyntax_error ( char * ffresult , int ffstate , int ffchar ) { int ffn = ffpact [ ffstate ] ; if ( ! ( FFPACT_NINF < ffn && ffn <= FFLAST ) ) return 0 ; else { int fftype = FFTRANSLATE ( ffchar ) ; FFSIZE_T ffsize0 = fftnamerr ( 0 , fftname [ fftype ] ) ; FFSIZE_T ffsize = ffsize0 ; FFSIZE_T ffsize1 ; int ffsize_overflow = 0 ; enum { FFERROR_VERBOSE_ARGS_MAXIMUM = 5 } ; char const * ffarg [ FFERROR_VERBOSE_ARGS_MAXIMUM ] ; int ffx ; # if 0 FF_ ( " " ) ; FF_ ( " " ) ; FF_ ( " " ) ; FF_ ( " " ) ; FF_ ( " " ) ; # endif char * fffmt ; char const * fff ; static char const ffunexpected [ ] = " " ; static char const ffexpecting [ ] = " " ; static char const ffor [ ] = " " ; char ffformat [ sizeof ffunexpected + sizeof ffexpecting - 1 + ( ( FFERROR_VERBOSE_ARGS_MAXIMUM - 2 ) * ( sizeof ffor - 1 ) ) ] ; char const * ffprefix = ffexpecting ; int ffxbegin = ffn < 0 ? - ffn : 0 ; int ffchecklim = FFLAST - ffn + 1 ; int ffxend = ffchecklim < FFNTOKENS ? ffchecklim : FFNTOKENS ; int ffcount = 1 ; ffarg [ 0 ] = fftname [ fftype ] ; fffmt = ffstpcpy ( ffformat , ffunexpected ) ; for ( ffx = ffxbegin ; ffx < ffxend ; ++ ffx ) if ( ffcheck [ ffx + ffn ] == ffx && ffx != FFTERROR ) { if ( ffcount == FFERROR_VERBOSE_ARGS_MAXIMUM ) { ffcount = 1 ; ffsize = ffsize0 ; ffformat [ sizeof ffunexpected - 1 ] = ' \0 ' ; break ; } ffarg [ ffcount ++ ] = fftname [ ffx ] ; ffsize1 = ffsize + fftnamerr ( 0 , fftname [ ffx ] ) ; ffsize_overflow |= ( ffsize1 < ffsize ) ; ffsize = ffsize1 ; fffmt = ffstpcpy ( fffmt , ffprefix ) ; ffprefix = ffor ; } fff = FF_ ( ffformat ) ; ffsize1 = ffsize + ffstrlen ( fff ) ; ffsize_overflow |= ( ffsize1 < ffsize ) ; ffsize = ffsize1 ; if ( ffsize_overflow ) return FFSIZE_MAXIMUM ; if ( ffresult ) { char * ffp = ffresult ; int ffi = 0 ; while ( ( * ffp = * fff ) != ' \0 ' ) { if ( * ffp == ' ' && fff [ 1 ] == ' ' && ffi < ffcount ) { ffp += fftnamerr ( ffp , ffarg [ ffi ++ ] ) ; fff += 2 ; } else { ffp ++ ; fff ++ ; } } } return ffsize ; } }
Copy into FFRESULT an error message about the unexpected token
FFCHAR while in state FFSTATE.
Copy into FFRESULT an error message about the unexpected token FFCHAR while in state FFSTATE .
/* This is so xgettext sees the translatable formats that are
	 constructed on the fly.  */ /* Start FFX at -FFN if negative to avoid negative indexes in
	 FFCHECK.  */ /* Stay within bounds of both ffcheck and fftname.  */ /* Avoid sprintf, as that infringes on the user's name space.
	     Don't have undefined behavior even if the translation
	     produced a string with the wrong number of "%s"s.  */