@@ -289,71 +289,72 @@ sub ParseData
289
289
290
290
if ($preserve_formatting )
291
291
{
292
- # Scan the input file.
293
- while (<$ifd >)
294
- {
295
- my $hash_ref ;
296
-
297
- if (/ {/ )
292
+ # Scan the input file.
293
+ while (<$ifd >)
298
294
{
299
- # Capture the hash ref
300
- # NB: Assumes that the next hash ref can't start on the
301
- # same line where the present one ended.
302
- # Not foolproof, but we shouldn't need a full parser,
303
- # since we expect relatively well-behaved input.
304
-
305
- # Quick hack to detect when we have a full hash ref to
306
- # parse. We can't just use a regex because of values in
307
- # pg_aggregate and pg_proc like '{0,0}'. This will need
308
- # work if we ever need to allow unbalanced braces within
309
- # a field value.
310
- my $lcnt = tr / {// ;
311
- my $rcnt = tr / }// ;
312
-
313
- if ($lcnt == $rcnt )
295
+ my $hash_ref ;
296
+
297
+ if (/ {/ )
314
298
{
315
- # We're treating the input line as a piece of Perl, so we
316
- # need to use string eval here. Tell perlcritic we know what
317
- # we're doing.
318
- eval ' $hash_ref = ' . $_ ; # # no critic (ProhibitStringyEval)
319
- if (!ref $hash_ref )
299
+ # Capture the hash ref
300
+ # NB: Assumes that the next hash ref can't start on the
301
+ # same line where the present one ended.
302
+ # Not foolproof, but we shouldn't need a full parser,
303
+ # since we expect relatively well-behaved input.
304
+
305
+ # Quick hack to detect when we have a full hash ref to
306
+ # parse. We can't just use a regex because of values in
307
+ # pg_aggregate and pg_proc like '{0,0}'. This will need
308
+ # work if we ever need to allow unbalanced braces within
309
+ # a field value.
310
+ my $lcnt = tr / {// ;
311
+ my $rcnt = tr / }// ;
312
+
313
+ if ($lcnt == $rcnt )
320
314
{
321
- die " $input_file : error parsing line $. :\n $_ \n " ;
322
- }
315
+ # We're treating the input line as a piece of Perl, so we
316
+ # need to use string eval here. Tell perlcritic we know what
317
+ # we're doing.
318
+ eval ' $hash_ref = '
319
+ . $_ ; # # no critic (ProhibitStringyEval)
320
+ if (!ref $hash_ref )
321
+ {
322
+ die " $input_file : error parsing line $. :\n $_ \n " ;
323
+ }
324
+
325
+ # Annotate each hash with the source line number.
326
+ $hash_ref -> {line_number } = $. ;
323
327
324
- # Annotate each hash with the source line number.
325
- $hash_ref -> {line_number } = $. ;
328
+ # Expand tuples to their full representation.
329
+ AddDefaultValues($hash_ref , $schema , $catname );
330
+ }
331
+ else
332
+ {
333
+ my $next_line = <$ifd >;
334
+ die " $input_file : file ends within Perl hash\n "
335
+ if !defined $next_line ;
336
+ $_ .= $next_line ;
337
+ redo ;
338
+ }
339
+ }
326
340
327
- # Expand tuples to their full representation.
328
- AddDefaultValues($hash_ref , $schema , $catname );
341
+ # If we found a hash reference, keep it, unless it is marked as
342
+ # autogenerated; in that case it'd duplicate an entry we'll
343
+ # autogenerate below. (This makes it safe for reformat_dat_file.pl
344
+ # with --full-tuples to print autogenerated entries, which seems like
345
+ # useful behavior for debugging.)
346
+ #
347
+ # Otherwise, we have a non-data string, which we need to keep in
348
+ # order to preserve formatting.
349
+ if (defined $hash_ref )
350
+ {
351
+ push @$data , $hash_ref if !$hash_ref -> {autogenerated };
329
352
}
330
353
else
331
354
{
332
- my $next_line = <$ifd >;
333
- die " $input_file : file ends within Perl hash\n "
334
- if !defined $next_line ;
335
- $_ .= $next_line ;
336
- redo ;
355
+ push @$data , $_ ;
337
356
}
338
357
}
339
-
340
- # If we found a hash reference, keep it, unless it is marked as
341
- # autogenerated; in that case it'd duplicate an entry we'll
342
- # autogenerate below. (This makes it safe for reformat_dat_file.pl
343
- # with --full-tuples to print autogenerated entries, which seems like
344
- # useful behavior for debugging.)
345
- #
346
- # Otherwise, we have a non-data string, which we need to keep in
347
- # order to preserve formatting.
348
- if (defined $hash_ref )
349
- {
350
- push @$data , $hash_ref if !$hash_ref -> {autogenerated };
351
- }
352
- else
353
- {
354
- push @$data , $_ ;
355
- }
356
- }
357
358
}
358
359
else
359
360
{
0 commit comments