The R Project SVN R-packages

Rev

Rev 2 | Rev 2321 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 957
Line 103... Line 103...
103
  str = fmt_to_string (spec);
103
  str = fmt_to_string (spec);
104
  if (spec->type == FMT_X)
104
  if (spec->type == FMT_X)
105
    return 1;
105
    return 1;
106
  if (f->cat & FCAT_OUTPUT_ONLY)
106
  if (f->cat & FCAT_OUTPUT_ONLY)
107
    {
107
    {
108
      error("Format %s may not be used as an input format.", f->name);
108
      error(_("format %s may not be used as an input format"), f->name);
109
      return 0;
109
      return 0;
110
    }
110
    }
111
  if (spec->w < f->Imin_w || spec->w > f->Imax_w)
111
  if (spec->w < f->Imin_w || spec->w > f->Imax_w)
112
    {
112
    {
113
      error("Input format %s specifies a bad width %d.  "
113
      error(_("input format %s specifies a bad width %d.  Format %s requires a width between %d and %d"),
114
		 "Format %s requires a width between %d and %d.",
-
 
115
	   str, spec->w, f->name, f->Imin_w, f->Imax_w);
114
	   str, spec->w, f->name, f->Imin_w, f->Imax_w);
116
      return 0;
115
      return 0;
117
    }
116
    }
118
  if ((f->cat & FCAT_EVEN_WIDTH) && spec->w % 2)
117
  if ((f->cat & FCAT_EVEN_WIDTH) && spec->w % 2)
119
    {
118
    {
120
      error ("Input format %s specifies an odd width %d, but "
119
      error (_("input format %s specifies an odd width %d, but format %s requires an even width between %d and %d"), 
121
		 "format %s requires an even width between %d and "
-
 
122
		 "%d.", str, spec->w, f->name, f->Imin_w, f->Imax_w);
120
	     str, spec->w, f->name, f->Imin_w, f->Imax_w);
123
      return 0;
121
      return 0;
124
    }
122
    }
125
  if (f->n_args > 1 && (spec->d < 0 || spec->d > 16))
123
  if (f->n_args > 1 && (spec->d < 0 || spec->d > 16))
126
    {
124
    {
127
      error ("Input format %s specifies a bad number of "
125
      error (_("Input format %s specifies a bad number of implied decimal places %d.  Input format %s allows up to 16 implied decimal places"), 
128
		 "implied decimal places %d.  Input format %s allows "
-
 
129
		 "up to 16 implied decimal places.", str, spec->d, f->name);
126
	     str, spec->d, f->name);
130
      return 0;
127
      return 0;
131
    }
128
    }
132
  return 1;
129
  return 1;
133
}
130
}
134
 
131
 
Line 142... Line 139...
142
  str = fmt_to_string (spec);
139
  str = fmt_to_string (spec);
143
  if (spec->type == FMT_X)
140
  if (spec->type == FMT_X)
144
    return 1;
141
    return 1;
145
  if (spec->w < f->Omin_w || spec->w > f->Omax_w)
142
  if (spec->w < f->Omin_w || spec->w > f->Omax_w)
146
    {
143
    {
147
      error ("Output format %s specifies a bad width %d.  "
144
      error (_("output format %s specifies a bad width %d.  Format %s requires a width between %d and %d"),
148
		 "Format %s requires a width between %d and %d.",
-
 
149
	   str, spec->w, f->name, f->Omin_w, f->Omax_w);
145
	   str, spec->w, f->name, f->Omin_w, f->Omax_w);
150
      return 0;
146
      return 0;
151
    }
147
    }
152
  if (spec->d > 1
148
  if (spec->d > 1
153
      && (spec->type == FMT_F || spec->type == FMT_COMMA
149
      && (spec->type == FMT_F || spec->type == FMT_COMMA
154
	  || spec->type == FMT_DOLLAR)
150
	  || spec->type == FMT_DOLLAR)
155
      && spec->w < f->Omin_w + 1 + spec->d)
151
      && spec->w < f->Omin_w + 1 + spec->d)
156
    {
152
    {
157
      error ("Output format %s requires minimum width %d to allow "
153
      error (_("output format %s requires minimum width %d to allow %d decimal places.  Try %s%d.%d instead of %s"),
158
		 "%d decimal places.  Try %s%d.%d instead of %s.",
-
 
159
	   f->name, f->Omin_w + 1 + spec->d, spec->d, f->name,
154
	   f->name, f->Omin_w + 1 + spec->d, spec->d, f->name,
160
	   f->Omin_w + 1 + spec->d, spec->d, str);
155
	   f->Omin_w + 1 + spec->d, spec->d, str);
161
      return 0;
156
      return 0;
162
    }
157
    }
163
  if ((f->cat & FCAT_EVEN_WIDTH) && spec->w % 2)
158
  if ((f->cat & FCAT_EVEN_WIDTH) && spec->w % 2)
164
    {
159
    {
165
      error ("Output format %s specifies an odd width %d, but "
160
      error (_("output format %s specifies an odd width %d, but output format %s requires an even width between %d and %d"), 
166
		 "output format %s requires an even width between %d and "
-
 
167
		 "%d.", str, spec->w, f->name, f->Omin_w, f->Omax_w);
161
	     str, spec->w, f->name, f->Omin_w, f->Omax_w);
168
      return 0;
162
      return 0;
169
    }
163
    }
170
  if (f->n_args > 1 && (spec->d < 0 || spec->d > 16))
164
  if (f->n_args > 1 && (spec->d < 0 || spec->d > 16))
171
    {
165
    {
172
      error ("Output format %s specifies a bad number of "
166
      error (_("Output format %s specifies a bad number of implied decimal places %d.  Output format %s allows a number of implied decimal places between 1 and 16"),
173
		 "implied decimal places %d.  Output format %s allows "
-
 
174
		 "a number of implied decimal places between 1 "
-
 
175
		 "and 16.", str, spec->d, f->name);
167
	  str, spec->d, f->name);
176
      return 0;
168
      return 0;
177
    }
169
    }
178
  return 1;
170
  return 1;
179
}
171
}
180
 
172
 
Line 184... Line 176...
184
check_string_specifier (const struct fmt_spec *f, int min_len)
176
check_string_specifier (const struct fmt_spec *f, int min_len)
185
{
177
{
186
  if ((f->type == FMT_A && min_len > f->w)
178
  if ((f->type == FMT_A && min_len > f->w)
187
      || (f->type == FMT_AHEX && min_len * 2 > f->w))
179
      || (f->type == FMT_AHEX && min_len * 2 > f->w))
188
    {
180
    {
189
      error ("Can't display a string variable of width %d with "
181
      error (_("cannot display a string variable of width %d with format specifier %s"),
190
		 "format specifier %s.", min_len, fmt_to_string (f));
182
	     min_len, fmt_to_string (f));
191
      return 0;
183
      return 0;
192
    }
184
    }
193
  return 1;
185
  return 1;
194
}
186
}
195
 
187
 
Line 296... Line 288...
296
  char *cp2;
288
  char *cp2;
297
  int type, w, d;
289
  int type, w, d;
298
 
290
 
299
  if (token != T_ID)
291
  if (token != T_ID)
300
    {
292
    {
301
      error ("Format specifier expected."));
293
      error ("format specifier expected");
302
      return 0;
294
      return 0;
303
    }
295
    }
304
  type = parse_format_specifier_name (&cp, allow_xt);
296
  type = parse_format_specifier_name (&cp, allow_xt);
305
  if (type == -1)
297
  if (type == -1)
306
    return 0;
298
    return 0;