From 01a211e142294c2165799c21047d1ee1b1e584a6 Mon Sep 17 00:00:00 2001 From: genoa Date: Sat, 3 Jul 1993 06:35:07 +0000 Subject: [PATCH] Works. --- backup/esqlc_fix.pl | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/backup/esqlc_fix.pl b/backup/esqlc_fix.pl index f7366d49..559ba729 100644 --- a/backup/esqlc_fix.pl +++ b/backup/esqlc_fix.pl @@ -1,14 +1,15 @@ -#!/usr/athena/bin/perl +#!/usr/athena/bin/perl -i.bak -# Dependencies: +# Limitations: # 1. Schema must have "create table tablename" all on one line # 2. Fields (columns) must be declared "NOT NULL WITH DEFAULT" # 3. C variables corresponding to database fields must use the # database field name with "t_" prefixed. # 4. Field names, table names, and C "t_" variable names are of the same case +# 5. Only references within CURSOR loops are corrected. -# Step 1. Read the schema +# Step 1. Read the schema, so we know the proper field lengths open(SCHEMA,"../db/schema") || die "Could not open schema, stopped\n"; while() { @@ -22,27 +23,18 @@ while() { } -#while (($key,$value) = each %fields) { -# print $key . " = " . $value . "\n"; -#} - - # Step 2. Read the code to be cleaned up -# Pass through most lines -# Note the opening and closing of cursors -# Play with IIcsGetio. Change 4th argument +# Pass through most lines. +# Note the opening and closing of cursors. +# Play with IIcsGetio. Change 4th argument if it's wrong. while(<>) { if(/IIwritio\(.*"select.*from\s+(\w+)"\);/) { $table = $1; next; } - if(/IIcsGetio\((.*,.*,.*,(\d+),&?t_(\w+))\);/) - - { - - $arguments = $1; + if(/IIcsGetio\((.*,.*,.*,(\d+),&?t_(\w+))\);/) { $width = $2; $field = $3; @@ -50,10 +42,10 @@ while(<>) { $shouldbe = $fields{$tablefield}; if( $shouldbe && $shouldbe != $width ) { - print "Field " . $tablefield . " found with length " . $width . " -- " . " should be " . $shouldbe . ".\n"; + s/(\(.*,.*,.*,)(\d+),/\1$shouldbe,/; } } } continue { -# print; + print; } -- 2.45.2