PIPS
split_file.c File Reference
#include <stdio.h>
#include "genC.h"
#include "misc.h"
#include "pipsdbm.h"
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
+ Include dependency graph for split_file.c:

Go to the source code of this file.

Macros

#define isbegincomment(c)    ((c)=='!' || (c)=='*' || (c)=='c' || (c)=='C' || (c)=='#')
 added macros More...
 
#define issquote(c)   ((c)=='\'')
 
#define isdquote(c)   ((c)=='\"')
 
#define ishH(c)   ((c)=='h' || (c)=='H')
 
#define char2int(c)   ((int)((c)-'0'))
 
#define LINESIZE   200
 
#define BSZ   512
 not lint More...
 
#define true   1
 
#define false   0
 
#define trim(p)   while (*p == ' ' || *p == '\t') p++
 
#define allowed_first_char(c)    (((c)>='a' && (c)<='z') || ((c)>='A' && (c)<='Z') || ((c)=='_'))
 
#define allowed_char(c)    (allowed_first_char(c) || ((c)>='0' && (c)<='9'))
 
#define skippable_char(c)    ((c)==' ' || (c)=='\t' || (c)=='\r')
 
#define FREE_STRINGS
 
#define HOLL_ERROR
 

Functions

static char * hollerith_and_bangcomments (char *)
 
static char * look ()
 
static char * skiplab ()
 
static char * functs ()
 
static int scan_name ()
 
static void get_name ()
 
static char * full_name (char *dir, char *name)
 
static void get_name (char *name)
 
static int GetLine ()
 getline does not handle continuations... More...
 
static char * skip_comment_if_any (char *lines)
 
static int lend ()
 return 1 for 'end' alone on card (up to col. More...
 
static int lname (char *s, int look_for_entry)
 check for keywords for subprograms
return 0 if comment card, 1 if found name and put in arg string. More...
 
static int scan_name (char *s, char *ptr)
 
static char * functs (char *p)
 
static char * skiplab (char *p)
 if first 6 col. More...
 
static char * look (char *s, char *m)
 return 0 if m doesn't match initial part of s; otherwise return ptr to next char after m in s More...
 
static void put_upper_from_slash_till_dot_or_end (char *what, FILE *where)
 
static void print_name (FILE *o, char *name, int n, int upper)
 FC. More...
 
char * fsplit (char *dir_name, char *file_name, FILE *out)
 
static int blank_line_p (char *line)
 
char * process_bang_comments_and_hollerith (FILE *in, FILE *out)
 processing extracted for includes... More...
 

Variables

char fsplit_copyright []
 split_file.c More...
 
char fsplit_sccsid [] = "@(#)fsplit.c 5.5 (Berkeley) 3/12/91"
 not lint More...
 
static char buf [BSZ]
 
static FILE * ifp
 
static char * x
 
static char * mainp
 
static char * blkp
 
static struct stat sbuf
 
static int current_line_number = 0
 
static int implicit_program
 
static int implicit_blockdata_name
 FC. More...
 
static int implicit_program_name
 FC. More...
 
static int it_is_a_main
 FC. More...
 
static int it_is_an_entry
 FC. More...
 
static int in_squotes =0
 ADDITION: basic Hollerith constants handling FC 11 Apr 1997. More...
 
static int in_dquotes =0
 
static int in_id =0
 
static int in_hollerith =0
 

Macro Definition Documentation

◆ allowed_char

#define allowed_char (   c)     (allowed_first_char(c) || ((c)>='0' && (c)<='9'))

Definition at line 356 of file split_file.c.

◆ allowed_first_char

#define allowed_first_char (   c)     (((c)>='a' && (c)<='z') || ((c)>='A' && (c)<='Z') || ((c)=='_'))

Definition at line 353 of file split_file.c.

◆ BSZ

#define BSZ   512

not lint

Definition at line 156 of file split_file.c.

◆ char2int

#define char2int (   c)    ((int)((c)-'0'))

Definition at line 72 of file split_file.c.

◆ false

#define false   0

Definition at line 162 of file split_file.c.

◆ FREE_STRINGS

#define FREE_STRINGS
Value:
if (main_list) free(main_list), main_list = NULL; \
if (x) free(x), x = NULL; \
if (mainp) free(mainp), mainp = NULL; \
if (blkp) free(blkp), blkp = NULL;
void free(void *)
static char * mainp
Definition: split_file.c:159
static char * x
Definition: split_file.c:159
static char * blkp
Definition: split_file.c:159

Definition at line 468 of file split_file.c.

◆ HOLL_ERROR

#define HOLL_ERROR
Value:
"pips internal error: cannot process " \
"hollerith constants on continued lines (line %d)"

Definition at line 669 of file split_file.c.

◆ isbegincomment

#define isbegincomment (   c)     ((c)=='!' || (c)=='*' || (c)=='c' || (c)=='C' || (c)=='#')

added macros

Definition at line 67 of file split_file.c.

◆ isdquote

#define isdquote (   c)    ((c)=='\"')

Definition at line 70 of file split_file.c.

◆ ishH

#define ishH (   c)    ((c)=='h' || (c)=='H')

Definition at line 71 of file split_file.c.

◆ issquote

#define issquote (   c)    ((c)=='\'')

Definition at line 69 of file split_file.c.

◆ LINESIZE

#define LINESIZE   200

Definition at line 75 of file split_file.c.

◆ skippable_char

#define skippable_char (   c)     ((c)==' ' || (c)=='\t' || (c)=='\r')

Definition at line 359 of file split_file.c.

◆ trim

#define trim (   p)    while (*p == ' ' || *p == '\t') p++

Definition at line 169 of file split_file.c.

◆ true

#define true   1

Definition at line 161 of file split_file.c.

Function Documentation

◆ blank_line_p()

static int blank_line_p ( char *  line)
static

Definition at line 660 of file split_file.c.

661 {
662  if (!line) return 1;
663  while (*line)
664  if (!isspace((int) *line++))
665  return 0;
666  return 1;
667 }
static int line
FLEX_SCANNER.
Definition: scanner.c:852

References line.

Referenced by hollerith_and_bangcomments().

+ Here is the caller graph for this function:

◆ fsplit()

char* fsplit ( char *  dir_name,
char *  file_name,
FILE *  out 
)

output file

1 if got card in output file, 0 otherwise

1 if got name of subprog., 0 otherwise

??? 20 -> 80 because not checked... smaller than a line is ok ? FC

MALLOC STRINGS

look for a temp file that doesn't correspond to an existing file

FC

if no name yet, try and find one

FC: some hack to deal with entry...

FC again

now we gave it a name!

a new module name is appended to the current line...

look for an 'end' statement

while

no lines in file, forget the file

rename the file

out?

for(;;)

Parameters
dir_nameir_name
file_nameile_name
outut

Definition at line 474 of file split_file.c.

475 {
476  FILE *ofp; /* output file */
477  int rv; /* 1 if got card in output file, 0 otherwise */
478  int nflag, /* 1 if got name of subprog., 0 otherwise */
479  someentry, newname;
480  /* ??? 20 -> 80 because not checked... smaller than a line is ok ? FC */
481  char name[80];
482  char tmpname[80];
483 
484  /* MALLOC STRINGS
485  */
486  char * main_list = full_name(dir_name, MAIN_FILE_NAMES);
487  x = full_name(dir_name, "###000.f");
488  mainp = full_name(dir_name, "main000.f");
489  blkp = full_name(dir_name, "data000.f");
490 
492 
493  if ((ifp = fopen(file_name, "r")) == NULL) {
494  fprintf(stderr, "fsplit: cannot open %s\n", file_name);
495  FREE_STRINGS;
496  return "cannot open file";
497  }
498 
499  for(;;) {
500 
501  /* look for a temp file that doesn't correspond to an existing file */
502  get_name(x);
503  ofp = fopen(x, "w");
504  if (ofp==NULL) {
505  fprintf(stderr, "%s %s -> %s\n", dir_name, file_name, x);
506  fprintf(stderr, "fopen(\"%s\", ...) failed\n", x);
507  abort();
508  }
509 
510  nflag = 0;
511  rv = 0;
512  newname = 0;
513  someentry = 0;
514 
515  while (GetLine() > 0)
516  {
517  char * error = hollerith_and_bangcomments(buf); /* FC */
518  if (error) {
519  fclose(ofp);
520  fclose(ifp);
521  FREE_STRINGS;
522  return error;
523  }
524 
525  if (nflag == 0) /* if no name yet, try and find one */
526  nflag = lname(name, 0), newname=nflag;
527  else { /* FC: some hack to deal with entry... */
528  lname(tmpname, 1);
529  newname = it_is_an_entry;
530  someentry = it_is_an_entry;
531  implicit_program = 0;
532  it_is_a_main = 0;
533  it_is_an_entry = 0;
534  }
535 
536  if (it_is_a_main) {
537  FILE * fm = fopen(main_list, "a");
538  if (fm==NULL) {
539  fprintf(stderr, "fopen(\"%s\", ...) failed\n", main_list);
540  // FI: not user friendly...
541  abort();
542  }
544  print_name(fm, name, 7, 1);
545  else
547  putc('\n', fm);
548  fclose(fm);
549  it_is_a_main = 0;
550  }
551 
552  if (implicit_program==1) /* FC again */
553  {
554  fprintf(ofp,
555  "! next line added by fsplit() in pips\n"
556  " PROGRAM ");
557  print_name(ofp, name, 7, 0);
558  putc('\n', ofp);
559  implicit_program = 0; /* now we gave it a name! */
560  }
561 
563  {
564  fprintf(ofp,
565  "! next line modified by fsplit() in pips\n"
566  " %s ",
567  implicit_program_name==1? "PROGRAM": "BLOCK DATA");
568  print_name(ofp, name, 7, 0);
569  putc('\n', ofp);
572  }
573  else
574  fprintf(ofp, "%s", buf);
575 
576  /* a new module name is appended to the current line... */
577  if (newname)
578  {
579  if ((someentry && tmpname[0]) || (!someentry && name[0]))
580  {
582  (someentry? tmpname: name, out);
583  putc(' ', out);
584  }
585  newname = 0;
586  someentry = 0;
587  tmpname[0] = '\0';
588  }
589 
590  rv = 1;
591 
592  if (lend()) /* look for an 'end' statement */
593  break;
594  } /* while */
595 
596  if (fclose(ofp)) {
597  fprintf(stderr, "fclose(ofp) failed\n");
598  exit(2);
599  }
600  if (rv == 0) { /* no lines in file, forget the file */
601  safe_unlink(x);
602  if (fclose(ifp)) {
603  fprintf(stderr, "fclose(ifp) failed\n");
604  exit(2);
605  }
606  FREE_STRINGS; return NULL;
607  }
608  if (nflag) /* rename the file */
609  {
610  if (strncmp(dir_name, name, strlen(dir_name))!=0)
611  {
612  char * full = full_name(dir_name, name);
613  strcpy(name, full);
614  free(full);
615  }
616  if (strcmp(name, x) == 0) {
617  printf(/* out? */ "%s\n", x);
618  }
619  else if (stat(name, &sbuf) < 0 )
620  {
621  int ok = link(x, name);
622  // FC: link() may fail but it is ok?
623  if (ok != 0 && ok != -1) abort();
624  safe_unlink(x);
625  fprintf(out, "%s\n", name);
626  }
627  else
628  printf("%s already exists, put in %s\n", name, x);
629  continue;
630  }
631  fprintf(out, "%s\n", x);
632  } /* for(;;) */
633 
634  if (fclose(ifp)) {
635  fprintf(stderr, "fclose(ifp) failed\n");
636  exit(2);
637  }
638  FREE_STRINGS;
639  return "bad fsplit() terminaison.";
640 }
#define error(fun, msg)
NewGen interface with C3 type Psysteme for PIPS project.
Definition: Psc.c:78
static FILE * out
Definition: alias_check.c:128
void safe_unlink(const char *file_name)
Delete the given file.
Definition: file.c:852
#define exit(code)
Definition: misc-local.h:54
#define abort()
Definition: misc-local.h:53
#define MAIN_FILE_NAMES
Name of the file containing the names of the main procedures.
Definition: pipsdbm-local.h:41
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
int printf()
static bool ok
static void put_upper_from_slash_till_dot_or_end(char *what, FILE *where)
Definition: split_file.c:452
static int lend()
return 1 for 'end' alone on card (up to col.
Definition: split_file.c:242
static char * hollerith_and_bangcomments(char *)
Definition: split_file.c:673
static int lname(char *s, int look_for_entry)
check for keywords for subprograms return 0 if comment card, 1 if found name and put in arg string.
Definition: split_file.c:283
static int it_is_an_entry
FC.
Definition: split_file.c:277
static int current_line_number
Definition: split_file.c:200
static FILE * ifp
Definition: split_file.c:158
static void print_name(FILE *o, char *name, int n, int upper)
FC.
Definition: split_file.c:462
static int implicit_program_name
FC.
Definition: split_file.c:275
static char buf[BSZ]
Definition: split_file.c:157
static void get_name()
static int implicit_blockdata_name
FC.
Definition: split_file.c:274
static int it_is_a_main
FC.
Definition: split_file.c:276
static char * full_name(char *dir, char *name)
Definition: split_file.c:171
static struct stat sbuf
Definition: split_file.c:163
static int implicit_program
Definition: split_file.c:273
static int GetLine()
getline does not handle continuations...
Definition: split_file.c:204
#define FREE_STRINGS
Definition: split_file.c:468
@ full
Definition: union-local.h:65
static string file_name

Referenced by pips_split_file().

+ Here is the caller graph for this function:

◆ full_name()

static char* full_name ( char *  dir,
char *  name 
)
static

Definition at line 171 of file split_file.c.

172 {
173  char * full = (char*) malloc(sizeof(char)*(strlen(dir)+strlen(name)+2));
174  sprintf(full, "%s/%s", dir, name);
175  return full;
176 }
void * malloc(YYSIZE_T)

◆ functs() [1/2]

static char * functs ( )

◆ functs() [2/2]

static char* functs ( char *  p)
static

look for typed functions such as: real*8 function, character*16 function, character*(*) function

Definition at line 391 of file split_file.c.

393 {
394  register char *ptr;
395 
396 /* look for typed functions such as: real*8 function,
397  character*16 function, character*(*) function */
398 
399  if((ptr = look(p,"character")) != 0 ||
400  (ptr = look(p,"logical")) != 0 ||
401  (ptr = look(p,"real")) != 0 ||
402  (ptr = look(p,"integer")) != 0 ||
403  (ptr = look(p,"doubleprecision")) != 0 ||
404  (ptr = look(p,"complex")) != 0 ||
405  (ptr = look(p,"doublecomplex")) != 0 ) {
406  while ( *ptr == ' ' || *ptr == '\t' || *ptr == '*'
407  || (*ptr >= '0' && *ptr <= '9')
408  || *ptr == '(' || *ptr == ')') ptr++;
409  ptr = look(ptr,"function");
410  return(ptr);
411  }
412  else
413  return(0);
414 }
static char * look()

◆ get_name() [1/2]

static void get_name ( )
static

◆ get_name() [2/2]

static void get_name ( char *  name)
static

Definition at line 178 of file split_file.c.

180 {
181  register char *ptr;
182 
183  while (stat(name, &sbuf) >= 0)
184  {
185  ptr = name + strlen(name) - 1;
186  while (!isdigit((int) *ptr--) && ptr>name);
187  for (ptr++; isdigit((int) *ptr) && ptr>name; ptr--) {
188  (*ptr)++;
189  if (*ptr <= '9')
190  break;
191  *ptr = '0';
192  }
193  if(ptr < name ) {
194  fprintf( stderr, "fsplit: ran out of file names\n");
195  exit(1);
196  }
197  }
198 }

◆ GetLine()

static int GetLine ( )
static

getline does not handle continuations...

fix for the last line that may not have a
. It is returned however and lend handles it correctly.

Definition at line 204 of file split_file.c.

205 {
206  register char *ptr;
207 
209 
210  if (feof(ifp)) return -1;
211 
212  for (ptr = buf; ptr < &buf[BSZ]; ) {
213  *ptr = getc(ifp);
214  /* fix for the last line that may not have a \n.
215  * It is returned however and lend handles it correctly.
216  */
217  if (feof(ifp) || *ptr++ == '\n')
218  {
219  *ptr = 0;
220  return (1);
221  }
222  }
223  while (getc(ifp) != '\n' && feof(ifp) == 0) ;
224  fprintf(stderr, "line truncated to %d characters\n", BSZ);
225  return (1);
226 }
#define BSZ
not lint
Definition: split_file.c:156

Referenced by process_bang_comments_and_hollerith().

+ Here is the caller graph for this function:

◆ hollerith_and_bangcomments()

static char * hollerith_and_bangcomments ( char *  line)
static

RESET

first column to analyze

RESET

73.. ignored

hack for real*8 hollerith

looks for [0-9 ]+[hH]

YEAH, here it is!

rm potential 73-80 text

should look for a continuation OR pad.

padding

must insert tmp[<j] in line[ni..] first, shift the line...

to the left

to the right

bang comment in the middle of a line.

stop while loop

the new line may exceed the 72 column

caution, len includes cr...

the dilatation cannot exceed one line (?)

then shift and continuation...

the bang comment is moved to the preceding line.

Definition at line 673 of file split_file.c.

674 {
675  int i,j,initial, touched=0, bang=0;
676  char bangcomment[BSZ];
677 
678  bangcomment[0] = '\0';
679 
680  if (!line) {
681  in_squotes=0, in_dquotes=0, in_id=0, in_hollerith=0; /* RESET */
682  return NULL;
683  }
684 
685  if (blank_line_p(line))
686  return NULL;
687 
688  if (isbegincomment(line[0]))
689  return NULL;
690 
691  i = (line[0]=='\t')? 1: 6; /* first column to analyze */
692 
693  for (j=0; j<i; j++)
694  if (!line[j]) return NULL;
695 
696  if (isspace((int) line[i-1]))
697  in_squotes=0, in_dquotes=0, in_id=0, in_hollerith=0; /* RESET */
698 
699  initial=i;
700 
701  while (line[i] && initial<72) /* 73.. ignored */
702  {
703  if (!in_dquotes && issquote(line[i]))
705  if (!in_squotes && isdquote(line[i]))
707  if (!in_squotes && !in_dquotes)
708  {
709  if (isalpha((int) line[i]))
710  in_id=1;
711  else if (!isalnum((int) line[i]) && !isspace((int) line[i])
712  && line[i]!='*') /* hack for real*8 hollerith */
713  in_id=0;
714  }
715 
716  if (!in_squotes && !in_dquotes && !in_id && isdigit((int) line[i]))
717  {
718  /* looks for [0-9 ]+[hH]
719  */
720  int len=char2int(line[i]), ni=i;
721  i++, initial++;
722 
723  while (line[i] && initial<72
724  && (isdigit((int) line[i]) || isspace((int) line[i])))
725  {
726  if (isdigit((int) line[i]))
727  len=10*len+char2int(line[i]);
728  i++, initial++;
729  }
730 
731  if (!line[i] || initial>=72) return NULL;
732 
733  if (ishH(line[i])) /* YEAH, here it is! */
734  {
735  char tmp[200];
736  int k;
737 
738  if (!touched) { /* rm potential 73-80 text */
739  touched=1;
740  line[72]='\n';
741  line[73]='\0';
742  }
743 
744  j=1;
745 
746  tmp[0] = '\''; i++, initial++;
747  while (j<200 && line[i] && initial<72 &&
748  line[i]!='\n' && len>0)
749  {
750  len--;
751  if (line[i]=='\'')
752  tmp[j++]='\'';
753  tmp[j++] = line[i++];
754  initial++;
755  }
756 
757  if (len!=0) /* should look for a continuation OR pad. */
758  {
759  if (initial==72)
760  {
761  char * msg = (char*) malloc((strlen(HOLL_ERROR)+10)*sizeof(char*));
762  (void) sprintf(msg, HOLL_ERROR, current_line_number);
763  return msg;
764  }
765  else
766  {
767  while (j<199 && len>0) /* padding */
768  tmp[j++]=' ', len--;
769  }
770  }
771 
772  tmp[j]='\'';
773 
774  /* must insert tmp[<j] in line[ni..]
775  * first, shift the line...
776  */
777 
778  {
779  int ll = strlen(line), shift = i-(ni+j+1);
780 
781  if (shift>0) /* to the left */
782  for (k=0; i+k<=ll; k++)
783  line[ni+j+1+k] = line[i+k];
784  else /* to the right */
785  for (k=ll-i; k>=0; k--)
786  line[ni+j+1+k] = line[i+k];
787  }
788 
789  i=ni+j+1;
790 
791  while(j>=0)
792  line[ni+j]=tmp[j], j--;
793 
794  }
795  }
796 
797  /* bang comment in the middle of a line. */
798  if (!in_squotes && !in_dquotes && line[i]=='!')
799  {
800  strcpy(bangcomment,&line[i]);
801  line[i]='\n', line[i+1]='\0'; /* stop while loop */
802  bang=1;
803  }
804 
805  i++, initial++;
806  }
807 
808  if (touched)
809  {
810  int len = strlen(line); /* the new line may exceed the 72 column */
811  /* caution, len includes cr... */
812  /* the dilatation cannot exceed one line (?) */
813  if (len-1>72) /* then shift and continuation... */
814  {
815  for (i=len; i>=72; i--) line[i+7] = line[i];
816  line[72]='\n'; line[73]=' '; line[74]=' ';
817  line[75]=' '; line[76]=' '; line[77]=' '; line[78]='x';
818  }
819  }
820 
821  /* the bang comment is moved to the preceding line.
822  */
823  if (bang)
824  {
825  char tmp[BSZ];
826  strcpy(tmp,line);
827  strcpy(line,bangcomment);
828  strcat(line,tmp);
829  }
830 
831  return NULL;
832 }
#define isdquote(c)
Definition: split_file.c:70
static int blank_line_p(char *line)
Definition: split_file.c:660
static int in_dquotes
Definition: split_file.c:658
static int in_squotes
ADDITION: basic Hollerith constants handling FC 11 Apr 1997.
Definition: split_file.c:658
static int in_id
Definition: split_file.c:658
static int in_hollerith
Definition: split_file.c:658
#define ishH(c)
Definition: split_file.c:71
#define isbegincomment(c)
added macros
Definition: split_file.c:67
#define HOLL_ERROR
Definition: split_file.c:669
#define issquote(c)
Definition: split_file.c:69
#define char2int(c)
Definition: split_file.c:72

References blank_line_p(), BSZ, char2int, current_line_number, HOLL_ERROR, in_dquotes, in_hollerith, in_id, in_squotes, isbegincomment, isdquote, ishH, issquote, line, and malloc().

Referenced by process_bang_comments_and_hollerith().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lend()

static int lend ( )
static

return 1 for 'end' alone on card (up to col.

72), 0 otherwise

a continuation

Definition at line 242 of file split_file.c.

243 {
244  register char *p, * lbuf;
245  int tab = false;
246 
247  lbuf = skip_comment_if_any(buf);
248 
249  for (p=lbuf; p<&lbuf[6] && !tab; p++)
250  {
251  if (*p=='\0') return 0;
252  if (*p=='\t') tab=true;
253  }
254 
255  if (!tab && (lbuf[5]!=' ' && lbuf[5]!='\t'))
256  return 0; /* a continuation */
257 
258  trim(p);
259  if (*p != 'e' && *p != 'E') return(0);
260  p++;
261  trim(p);
262  if (*p != 'n' && *p != 'N') return(0);
263  p++;
264  trim(p);
265  if (*p != 'd' && *p != 'D') return(0);
266  p++;
267  trim(p);
268  if (p - buf >= 72 || *p == '\n' || *p == '\r' || *p == '\0')
269  return (1);
270  return (0);
271 }
static char * skip_comment_if_any(char *lines)
Definition: split_file.c:228
#define trim(p)
Definition: split_file.c:169

Referenced by freia_migrate_statements().

+ Here is the caller graph for this function:

◆ lname()

static int lname ( char *  s,
int  look_for_entry 
)
static

check for keywords for subprograms
return 0 if comment card, 1 if found name and put in arg string.

invent name for unnamed block datas and main programs.

first check for comment cards

copy to buffer and converting to lower case

entry is looked for within a something...

Definition at line 283 of file split_file.c.

284 {
285  register char *ptr, *p;
286  char line[LINESIZE], *iptr = line, * lbuf;
287 
288  implicit_program = 0;
291  it_is_a_main = 0;
292  it_is_an_entry = 0;
293 
294  lbuf = skip_comment_if_any(buf);
295 
296  /* first check for comment cards */
297  if(isbegincomment(lbuf[0]))
298  return 0;
299  ptr = lbuf;
300  while (*ptr == ' ' || *ptr == '\t') ptr++;
301  if(*ptr == '\n') return(0);
302 
303  ptr = skiplab(lbuf);
304  if (ptr == 0) return (0);
305 
306  /* copy to buffer and converting to lower case */
307  p = ptr;
308  while (*p && p <= &lbuf[71] ) {
309  *iptr = isupper((int) *p) ? tolower(*p) : *p;
310  iptr++;
311  p++;
312  }
313  *iptr = '\n';
314 
315  if (look_for_entry) {
316  /* entry is looked for within a something... */
317  if ((ptr = look(line, "entry")) != 0)
318  if(scan_name(s, ptr))
319  it_is_an_entry = 1;
320  } else {
321  if ((ptr = look(line, "subroutine")) != 0 ||
322  (ptr = look(line, "function")) != 0 ||
323  (ptr = functs(line)) != 0) {
324  if(!scan_name(s, ptr))
325  strcpy( s, x);
326  } else if((ptr = look(line, "program")) != 0) {
327  it_is_a_main = 1;
328  if(!scan_name(s, ptr)) {
330  get_name( mainp);
331  strcpy( s, mainp);
332  }
333  } else if((ptr = look(line, "blockdata")) != 0) {
334  if(!scan_name(s, ptr)) {
336  get_name( blkp);
337  strcpy( s, blkp);
338  }
339  } else if((ptr = functs(line)) != 0) {
340  if(!scan_name(s, ptr))
341  strcpy( s, x);
342  } else {
343  implicit_program = 1;
344  it_is_a_main = 1;
345  get_name(mainp);
346  strcpy(s, mainp);
347  }
348  }
349 
350  return(1);
351 }
#define LINESIZE
Definition: split_file.c:75
static char * functs()
static char * skiplab()
static int scan_name()

Referenced by binary_to_nary(), c_text_related_entities(), language_module_p(), make_bound(), nary_operator_p(), set_control_to_label(), statement_remove_omp_clauses(), what_operator(), and words_basic().

+ Here is the caller graph for this function:

◆ look() [1/2]

static char* look ( )
static

◆ look() [2/2]

static char* look ( char *  s,
char *  m 
)
static

return 0 if m doesn't match initial part of s; otherwise return ptr to next char after m in s

Definition at line 438 of file split_file.c.

440 {
441  register char *sp, *mp;
442 
443  sp = s; mp = m;
444  while (*mp) {
445  trim(sp);
446  if (*sp++ != *mp++)
447  return (0);
448  }
449  return (sp);
450 }

◆ print_name()

static void print_name ( FILE *  o,
char *  name,
int  n,
int  upper 
)
static

FC.

Definition at line 462 of file split_file.c.

463 {
464  name = name + strlen(name) - n - 2;
465  while (n-->0) putc(upper? toupper(*name++): *name++, o);
466 }

◆ process_bang_comments_and_hollerith()

char* process_bang_comments_and_hollerith ( FILE *  in,
FILE *  out 
)

processing extracted for includes...

Parameters
inn
outut

Definition at line 836 of file split_file.c.

837 {
838  char * error;
839  ifp = in;
841  while (GetLine()>0)
842  {
844  if (error) return error;
845  fputs(buf, out);
846  }
847  ifp = NULL;
848  return NULL;
849 }

References buf, current_line_number, error, GetLine(), hollerith_and_bangcomments(), ifp, and out.

Referenced by handle_include_file().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ put_upper_from_slash_till_dot_or_end()

static void put_upper_from_slash_till_dot_or_end ( char *  what,
FILE *  where 
)
static

Definition at line 452 of file split_file.c.

453 {
454  if (*what=='.') {
455  char * tmp = what+strlen(what);
456  while (tmp>what && *tmp!='/') tmp--;
457  if (what!=tmp) what=tmp+1;
458  }
459  while (*what && *what!='.') putc(toupper(*what++), where);
460 }

◆ scan_name() [1/2]

static int scan_name ( )
static

◆ scan_name() [2/2]

static int scan_name ( char *  s,
char *  ptr 
)
static

scan off the name

must have a valid first char.

next char should be a ( or

Definition at line 362 of file split_file.c.

364 {
365  char *sptr;
366 
367  /* scan off the name */
368  trim(ptr);
369  sptr = s;
370 
371  /* must have a valid first char. */
372  if (!allowed_first_char(*ptr)) return 0;
373 
374  while (allowed_char(*ptr) || skippable_char(*ptr)) {
375  if (!skippable_char(*ptr))
376  *sptr++ = *ptr;
377  ptr++;
378  }
379 
380  if (sptr == s) return(0);
381 
382  /* next char should be a ( or \n */
383  if (*ptr!='(' && *ptr!='\n') return 0;
384 
385  *sptr++ = '.';
386  *sptr++ = 'f';
387  *sptr++ = 0;
388  return(1);
389 }
#define skippable_char(c)
Definition: split_file.c:359
#define allowed_first_char(c)
Definition: split_file.c:353
#define allowed_char(c)
Definition: split_file.c:356

◆ skip_comment_if_any()

static char* skip_comment_if_any ( char *  lines)
static

Definition at line 228 of file split_file.c.

229 {
230  int i = 0;
231 
232  while (isbegincomment(lines[i]))
233  {
234  while (lines[i]!='\0' && lines[i]!='\n') i++;
235  if (lines[i]=='\n') i++;
236  }
237 
238  return lines+i;
239 }
static GtkWidget * lines[HELP_LINES]
Definition: gtk_help.c:47

◆ skiplab() [1/2]

static char * skiplab ( )

◆ skiplab() [2/2]

static char* skiplab ( char *  p)
static

if first 6 col.

blank, return ptr to col. 7, if blanks and then tab, return ptr after tab, else return 0 (labelled statement, comment or continuation

Definition at line 419 of file split_file.c.

421 {
422  register char *ptr;
423 
424  for (ptr = p; ptr < &p[6]; ptr++) {
425  if (*ptr == ' ')
426  continue;
427  if (*ptr == '\t') {
428  ptr++;
429  break;
430  }
431  return (0);
432  }
433  return (ptr);
434 }

Variable Documentation

◆ blkp

char * blkp
static

Definition at line 159 of file split_file.c.

◆ buf

◆ current_line_number

int current_line_number = 0
static

◆ fsplit_copyright

char fsplit_copyright[]
Initial value:
=
"@(#) Copyright (c) 1983 The Regents of the University of California.\n\
All rights reserved.\n"

split_file.c

Definition at line 114 of file split_file.c.

◆ fsplit_sccsid

char fsplit_sccsid[] = "@(#)fsplit.c 5.5 (Berkeley) 3/12/91"

not lint

Definition at line 120 of file split_file.c.

◆ ifp

FILE* ifp
static

Definition at line 158 of file split_file.c.

Referenced by process_bang_comments_and_hollerith().

◆ implicit_blockdata_name

int implicit_blockdata_name
static

FC.

Definition at line 274 of file split_file.c.

◆ implicit_program

int implicit_program
static

Definition at line 273 of file split_file.c.

◆ implicit_program_name

int implicit_program_name
static

FC.

Definition at line 275 of file split_file.c.

◆ in_dquotes

int in_dquotes =0
static

Definition at line 658 of file split_file.c.

Referenced by hollerith_and_bangcomments().

◆ in_hollerith

int in_hollerith =0
static

Definition at line 658 of file split_file.c.

Referenced by hollerith_and_bangcomments().

◆ in_id

int in_id =0
static

Definition at line 658 of file split_file.c.

Referenced by hollerith_and_bangcomments().

◆ in_squotes

int in_squotes =0
static

ADDITION: basic Hollerith constants handling FC 11 Apr 1997.

bugs:

  • under special circonstances, the dilatation of the transformation may lead continuations to exceed the 19 lines limit.

to improve:

  • hack for "real*8 hollerith", but should just forbids start after *? maybe some other characters? global state

Definition at line 658 of file split_file.c.

Referenced by hollerith_and_bangcomments().

◆ it_is_a_main

int it_is_a_main
static

FC.

Definition at line 276 of file split_file.c.

◆ it_is_an_entry

int it_is_an_entry
static

FC.

Definition at line 277 of file split_file.c.

◆ mainp

char * mainp
static

Definition at line 159 of file split_file.c.

◆ sbuf

struct stat sbuf
static

Definition at line 159 of file split_file.c.

◆ x

char* x
static

Definition at line 159 of file split_file.c.

Referenced by add_bounding_box_constraints(), add_remapping_as_used(), allocate_bucket(), array_dimension_bound_test_undefined_p(), array_test_undefined_p(), average_probability_matrix(), bezout(), bezout_grl(), build_contraction_matrices(), build_convex_constraints_from_vertices(), check_coefficient_reduction(), check_if_direct_reference(), choisir_piv(), compare_attachment_for_qsort(), compare_option_type_for_qsort(), constant_constraint_check(), contrainte_make_1D(), convert_pointer_to_array(), cool_enough_for_a_last_substitution(), corr(), dilate_1d_h(), dilate_1d_v(), dprint(), eligible_for_coefficient_reduction_with_bounding_box_p(), erode_1d_h(), erode_1d_v(), eval_2D_vecteur(), exam_coef(), exponentiate(), expression_try_find_size(), find_eg(), find_first_integer_point_in_between(), find_integer_point_to_the_left(), find_integer_point_to_the_right(), find_intermediate_constraints(), find_intermediate_constraints_recursively(), find_or_allocate(), float_to_frac(), frac_div(), frac_mul(), free_bucket(), free_buckets(), gather_local_indices(), gaussian_noise_reduce(), gen_chunk_identity(), gen_identity(), gen_list_patch(), gen_set_closure_iterate(), gram_param(), include_trans_on_LC_in_ref(), initialization(), integrer(), llog(), loop_flt(), main(), MakeParameter(), MakeStatementLike(), mat_maj_col(), mat_maj_lig(), matrice_hermite(), matrice_smith(), matrice_soustraction_colonne(), matrice_soustraction_ligne(), matrice_unimodulaire_triangulaire_inversion(), matrix_hermite(), matrix_maj_col(), matrix_maj_line(), matrix_smith(), matrix_subtraction_column(), matrix_subtraction_line(), matrix_unimodular_triangular_inversion(), monome_sprint(), monome_to_expression(), my_matrices_to_constraints_with_sym_cst(), my_matrices_to_constraints_with_sym_cst_2(), new_constraint_for_coefficient_reduction_with_bounding_box(), number_of_buckets(), number_of_ordered_statements(), outliner_patch_parameters(), pipsdbm_consistent_statement_function(), pipsdbm_write_statement_function(), pivoter(), printfrac(), reduce_coefficients_with_bounding_box(), remapping_already_computed_p(), sc_min(), schoose_create_abbrev_menu_with_text(), signed_integer_constant_expression_value(), simplify_float_constraint(), small_positive_slope_reduce_coefficients_with_bounding_box(), sol_mod(), sol_pgcd(), sol_ppcm(), stack_head(), stack_map(), stack_pop(), stack_push(), stack_replace(), statement_arrows(), tab_display(), terapix_gram_allocate(), terapix_init_row(), term(), text_loop_craft(), traiter(), transformer_add_equality_with_affine_term(), transformer_add_inequality_with_affine_term(), transformer_add_inequality_with_linear_term(), update_coefficient_signs_in_constraints(), update_coefficient_signs_in_vector(), update_iterator_upward(), vect_cl_ofl_ctrl(), vect_div(), vect_in_p(), vect_make_1D(), vect_make_line(), vect_multiply(), vecteur_bezout(), and x_language_module_p().