+static bool
+parse_column__ (struct lexer *lexer, bool negative, int base, int *column)
+{
+ assert (base == 0 || base == 1);
+
+ if (!lex_force_int (lexer))
+ return false;
+ long int value = lex_integer (lexer);
+ if (negative)
+ value = -value;
+ lex_get (lexer);
+
+ *column = value - base + 1;
+ if (*column < 1)
+ {
+ if (base == 1)
+ lex_next_error (lexer, -1, -1,
+ _("Column positions for fields must be positive."));
+ else
+ lex_next_error (lexer, -1, -1,
+ _("Column positions for fields must not be negative."));
+ return false;
+ }
+ return true;
+}
+
+/* Parses a BASE-based column using LEXER. Returns true and
+ stores a 1-based column number into *COLUMN if successful,
+ otherwise emits an error message and returns false.
+
+ If BASE is 0, zero-based column numbers are parsed; if BASE is
+ 1, 1-based column numbers are parsed. Regardless of BASE, the
+ values stored in *FIRST_COLUMN and *LAST_COLUMN are
+ 1-based. */
+bool
+parse_column (struct lexer *lexer, int base, int *column)
+{
+ return parse_column__ (lexer, false, base, column);
+}
+