+2007-11-05 Ben Pfaff <blp@gnu.org>
+
+ Patch #6258. Reviewed by John Darrington.
+
+ * file-handle-def.c (fh_lock): Add comment that TYPE should be
+ marked with N_() in the caller. Added these markings to each
+ caller too. Should make i18n easier.
+ Suggested by Chusslove Illich <caslav.ilic@gmx.net>.
+
2007-11-03 Ben Pfaff <blp@gnu.org>
Allow output files to overwrite input files (bug #21280).
and similarly for writing. If successful, a reference to TYPE
is retained, so it should probably be a string literal.
+ TYPE should be marked with N_() in the caller: that is, the
+ caller should not translate it with gettext, but fh_lock will
+ do so.
+
ACCESS specifies whether the lock is for reading or writing.
EXCLUSIVE is true to require exclusive access, false to allow
sharing with other accessors. Exclusive read access precludes
#include "gettext.h"
#define _(msgid) gettext (msgid)
+#define N_(msgid) (msgid)
/* portable_to_local[PORTABLE] translates the given portable
character into the local character set. */
goto error;
/* Lock file. */
- r->lock = fh_lock (fh, FH_REF_FILE, "portable file", FH_ACC_READ, false);
+ /* TRANSLATORS: this fragment will be interpolated into
+ messages in fh_lock() that identify types of files. */
+ r->lock = fh_lock (fh, FH_REF_FILE, N_("portable file"), FH_ACC_READ, false);
if (r->lock == NULL)
goto error;
#include "gettext.h"
#define _(msgid) gettext (msgid)
+#define N_(msgid) (msgid)
/* Maximum width of a variable in a portable file. */
#define MAX_POR_WIDTH 255
}
/* Lock file. */
- w->lock = fh_lock (fh, FH_REF_FILE, "portable file", FH_ACC_WRITE, true);
+ /* TRANSLATORS: this fragment will be interpolated into
+ messages in fh_lock() that identify types of files. */
+ w->lock = fh_lock (fh, FH_REF_FILE, N_("portable file"), FH_ACC_WRITE, true);
if (w->lock == NULL)
goto error;
#include "xalloc.h"
+#define N_(msgid) (msgid)
+
/* A scratch file writer. */
struct scratch_writer
{
size_t dict_value_cnt;
/* Get exclusive write access to handle. */
- lock = fh_lock (fh, FH_REF_SCRATCH, "scratch file", FH_ACC_WRITE, true);
+ /* TRANSLATORS: this fragment will be interpolated into
+ messages in fh_lock() that identify types of files. */
+ lock = fh_lock (fh, FH_REF_SCRATCH, N_("scratch file"), FH_ACC_WRITE, true);
if (lock == NULL)
return NULL;
r->has_long_var_names = false;
r->opcode_idx = sizeof r->opcodes;
- r->lock = fh_lock (fh, FH_REF_FILE, "system file", FH_ACC_READ, false);
+ /* TRANSLATORS: this fragment will be interpolated into
+ messages in fh_lock() that identify types of files. */
+ r->lock = fh_lock (fh, FH_REF_FILE, N_("system file"), FH_ACC_READ, false);
if (r->lock == NULL)
goto error;
#include "gettext.h"
#define _(msgid) gettext (msgid)
+#define N_(msgid) (msgid)
/* Compression bias used by PSPP. Values between (1 -
COMPRESSION_BIAS) and (251 - COMPRESSION_BIAS) inclusive can be
&w->sfm_var_cnt);
/* Open file handle as an exclusive writer. */
- w->lock = fh_lock (fh, FH_REF_FILE, "system file", FH_ACC_WRITE, true);
+ /* TRANSLATORS: this fragment will be interpolated into
+ messages in fh_lock() that identify types of files. */
+ w->lock = fh_lock (fh, FH_REF_FILE, N_("system file"), FH_ACC_WRITE, true);
if (w->lock == NULL)
goto error;
+2007-11-05 Ben Pfaff <blp@gnu.org>
+
+ Patch #6258. Reviewed by John Darrington.
+
+ * command.c (report_state_mismatch): Replace code to construct an
+ error message from bits and pieces by a switch statement that
+ hard-codes each possible error. Makes i18n easier.
+ Suggested by Chusslove Illich <caslav.ilic@gmx.net>.
+
2007-09-22 Ben Pfaff <blp@gnu.org>
Bug #21128. Reviewed by John Darrington.
assert (!in_correct_state (command, state));
if (state == CMD_STATE_INITIAL || state == CMD_STATE_DATA)
{
- const char *allowed[3];
- int allowed_cnt;
- char *s;
-
- allowed_cnt = 0;
- if (command->states & S_INITIAL)
- allowed[allowed_cnt++] = _("before the active file has been defined");
- else if (command->states & S_DATA)
- allowed[allowed_cnt++] = _("after the active file has been defined");
- if (command->states & S_INPUT_PROGRAM)
- allowed[allowed_cnt++] = _("inside INPUT PROGRAM");
- if (command->states & S_FILE_TYPE)
- allowed[allowed_cnt++] = _("inside FILE TYPE");
-
- if (allowed_cnt == 1)
- s = xstrdup (allowed[0]);
- else if (allowed_cnt == 2)
- s = xasprintf (_("%s or %s"), allowed[0], allowed[1]);
- else if (allowed_cnt == 3)
- s = xasprintf (_("%s, %s, or %s"), allowed[0], allowed[1], allowed[2]);
- else
- NOT_REACHED ();
-
- msg (SE, _("%s is allowed only %s."), command->name, s);
-
- free (s);
+ switch (command->states)
+ {
+ /* One allowed state. */
+ case S_INITIAL:
+ msg (SE, _("%s is allowed only before the active file has "
+ "been defined."), command->name);
+ break;
+ case S_DATA:
+ msg (SE, _("%s is allowed only after the active file has "
+ "been defined."), command->name);
+ break;
+ case S_INPUT_PROGRAM:
+ msg (SE, _("%s is allowed only inside INPUT PROGRAM."),
+ command->name);
+ break;
+ case S_FILE_TYPE:
+ msg (SE, _("%s is allowed only inside FILE TYPE."), command->name);
+ break;
+
+ /* Two allowed states. */
+ case S_INITIAL | S_DATA:
+ NOT_REACHED ();
+ case S_INITIAL | S_INPUT_PROGRAM:
+ msg (SE, _("%s is allowed only before the active file has "
+ "been defined or inside INPUT PROGRAM."), command->name);
+ break;
+ case S_INITIAL | S_FILE_TYPE:
+ msg (SE, _("%s is allowed only before the active file has "
+ "been defined or inside FILE TYPE."), command->name);
+ break;
+ case S_DATA | S_INPUT_PROGRAM:
+ msg (SE, _("%s is allowed only after the active file has "
+ "been defined or inside INPUT PROGRAM."), command->name);
+ break;
+ case S_DATA | S_FILE_TYPE:
+ msg (SE, _("%s is allowed only after the active file has "
+ "been defined or inside FILE TYPE."), command->name);
+ break;
+ case S_INPUT_PROGRAM | S_FILE_TYPE:
+ msg (SE, _("%s is allowed only inside INPUT PROGRAM "
+ "or inside FILE TYPE."), command->name);
+ break;
+
+ /* Three allowed states. */
+ case S_DATA | S_INPUT_PROGRAM | S_FILE_TYPE:
+ msg (SE, _("%s is allowed only after the active file has "
+ "been defined, inside INPUT PROGRAM, or inside "
+ "FILE TYPE."), command->name);
+ break;
+ case S_INITIAL | S_INPUT_PROGRAM | S_FILE_TYPE:
+ msg (SE, _("%s is allowed only before the active file has "
+ "been defined, inside INPUT PROGRAM, or inside "
+ "FILE TYPE."), command->name);
+ break;
+ case S_INITIAL | S_DATA | S_FILE_TYPE:
+ NOT_REACHED ();
+ case S_INITIAL | S_DATA | S_INPUT_PROGRAM:
+ NOT_REACHED ();
+
+ /* Four allowed states. */
+ case S_INITIAL | S_DATA | S_INPUT_PROGRAM | S_FILE_TYPE:
+ NOT_REACHED ();
+
+ default:
+ NOT_REACHED ();
+ }
}
else if (state == CMD_STATE_INPUT_PROGRAM)
msg (SE, _("%s is not allowed inside INPUT PROGRAM."), command->name);
#include "gettext.h"
#define _(msgid) gettext (msgid)
+#define N_(msgid) (msgid)
/* Flags for DFM readers. */
enum dfm_reader_flags
struct dfm_reader *r;
struct fh_lock *lock;
- lock = fh_lock (fh, FH_REF_FILE | FH_REF_INLINE, "data file",
+ /* TRANSLATORS: this fragment will be interpolated into
+ messages in fh_lock() that identify types of files. */
+ lock = fh_lock (fh, FH_REF_FILE | FH_REF_INLINE, N_("data file"),
FH_ACC_READ, false);
if (lock == NULL)
return NULL;
#include "gettext.h"
#define _(msgid) gettext (msgid)
+#define N_(msgid) (msgid)
/* Data file writer. */
struct dfm_writer
struct dfm_writer *w;
struct fh_lock *lock;
- lock = fh_lock (fh, FH_REF_FILE, "data file", FH_ACC_WRITE, false);
+ lock = fh_lock (fh, FH_REF_FILE, N_("data file"), FH_ACC_WRITE, false);
if (lock == NULL)
return NULL;