goto exit;
handle_name = xstrdup (lex_tokcstr (lexer));
- if (fh_from_id (handle_name))
+ struct file_handle *fh = fh_from_id (handle_name);
+ if (fh)
{
- msg (SE, _("File handle %s is already defined. "
- "Use %s before redefining a file handle."),
- handle_name, "CLOSE FILE HANDLE");
+ fh_unref (fh);
+ lex_error (lexer, _("File handle %s is already defined. "
+ "Use %s before redefining a file handle."),
+ handle_name, "CLOSE FILE HANDLE");
goto exit;
}
if (!lex_force_match (lexer, T_SLASH))
goto exit;
+ int mode_start = 0;
+ int mode_end = 0;
while (lex_token (lexer) != T_ENDCMD)
{
if (lex_match_id (lexer, "NAME"))
{
if (file_name)
{
- lex_sbc_only_once ("NAME");
+ lex_sbc_only_once (lexer, "NAME");
goto exit;
}
{
if (lrecl)
{
- lex_sbc_only_once ("LRECL");
+ lex_sbc_only_once (lexer, "LRECL");
goto exit;
}
{
if (tabwidth >= 0)
{
- lex_sbc_only_once ("TABWIDTH");
+ lex_sbc_only_once (lexer, "TABWIDTH");
goto exit;
}
lex_match (lexer, T_EQUALS);
{
if (mode != MODE_DEFAULT)
{
- lex_sbc_only_once ("MODE");
+ lex_sbc_only_once (lexer, "MODE");
goto exit;
}
+ mode_start = lex_ofs (lexer) - 1;
lex_match (lexer, T_EQUALS);
if (lex_match_id (lexer, "CHARACTER"))
mode = MODE_360;
else
{
- lex_error (lexer, NULL);
+ lex_error_expecting (lexer, "CHARACTER", "BINARY",
+ "IMAGE", "360");
goto exit;
}
+ mode_end = lex_ofs (lexer) - 1;
}
else if (lex_match_id (lexer, "ENDS"))
{
if (ends >= 0)
{
- lex_sbc_only_once ("ENDS");
+ lex_sbc_only_once (lexer, "ENDS");
goto exit;
}
lex_match (lexer, T_EQUALS);
ends = FH_END_CRLF;
else
{
- lex_error (lexer, NULL);
+ lex_error_expecting (lexer, "LF", "CRLF");
goto exit;
}
}
{
if (recform)
{
- lex_sbc_only_once ("RECFORM");
+ lex_sbc_only_once (lexer, "RECFORM");
goto exit;
}
lex_match (lexer, T_EQUALS);
recform = RECFORM_SPANNED;
else
{
- lex_error (lexer, NULL);
+ lex_error_expecting (lexer, "FIXED", "VARIABLE", "SPANNED");
goto exit;
}
}
{
if (encoding)
{
- lex_sbc_only_once ("ENCODING");
+ lex_sbc_only_once (lexer, "ENCODING");
goto exit;
}
struct fh_properties properties = *fh_default_properties ();
if (file_name == NULL)
{
- lex_sbc_missing ("NAME");
+ lex_sbc_missing (lexer, "NAME");
goto exit;
}
}
else
{
- msg (SE, _("%s must be specified with %s."), "RECFORM", "MODE=360");
+ lex_ofs_error (lexer, mode_start, mode_end,
+ _("%s must be specified with %s."),
+ "RECFORM", "MODE=360");
goto exit;
}
break;
fh_parse (struct lexer *lexer, enum fh_referent referent_mask,
struct session *session)
{
- struct file_handle *handle;
-
if (session != NULL && lex_token (lexer) == T_ID)
{
struct dataset *ds;
}
}
+ int start_ofs = lex_ofs (lexer);
+ struct file_handle *handle;
if (lex_match_id (lexer, "INLINE"))
handle = fh_inline_file ();
else
{
if (lex_token (lexer) != T_ID && !lex_is_string (lexer))
{
- lex_error (lexer, _("expecting a file name or handle name"));
+ lex_error (lexer,
+ _("Syntax error expecting a file name or handle name."));
return NULL;
}
if (!(fh_get_referent (handle) & referent_mask))
{
- msg (SE, _("Handle for %s not allowed here."),
- referent_name (fh_get_referent (handle)));
+ lex_ofs_error (lexer, start_ofs, lex_ofs (lexer) - 1,
+ _("Handle for %s not allowed here."),
+ referent_name (fh_get_referent (handle)));
fh_unref (handle);
return NULL;
}