PostGIS  3.6.1dev-r@@SVN_REVISION@@

◆ is_format_valid()

static int is_format_valid ( const char *  format)
static

Definition at line 182 of file lwgeom_out_marc21.c.

182  {
183 
184  const char *dec_part = strchr(format, '.');
185  if(!dec_part) dec_part = strchr(format, ',');
186 
187  if(!dec_part) {
188 
189  if (strcmp(format, "hdddmmss") && strcmp(format, "dddmmss")) {
190 
191  return LW_FALSE;
192 
193  }
194 
195  } else {
196  char* int_part;
197  const size_t dec_part_len = strlen(dec_part);
198  const size_t int_part_len = (size_t)(dec_part - format);
199  if(int_part_len == 0 || dec_part_len<2) return LW_FALSE;
200 
201  int_part = palloc(int_part_len + 1);
202  memcpy(int_part, &format[0], int_part_len);
203  int_part[int_part_len]='\0';
204 
205  if (strcmp(int_part,"hddd") && strcmp(int_part,"ddd") &&
206  strcmp(int_part,"hdddmm") && strcmp(int_part,"dddmm") &&
207  strcmp(int_part,"hdddmmss") && strcmp(int_part,"dddmmss")) {
208 
209  pfree(int_part);
210  return LW_FALSE;
211 
212  }
213 
214  for (size_t i = 1; i < dec_part_len; i++) {
215 
216  if(dec_part[i]!=int_part[int_part_len-1]) {
217 
218  pfree(int_part);
219  return LW_FALSE;
220  }
221  }
222 
223  pfree(int_part);
224 
225  }
226 
227  return LW_TRUE;
228 
229 }
#define LW_FALSE
Definition: liblwgeom.h:94
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93

References LW_FALSE, and LW_TRUE.

Referenced by lwgeom_to_marc21().

Here is the caller graph for this function: