Install sccs headers and copyright notices.
[unix-history] / usr / src / usr.bin / tn3270 / tools / mkmake.y
index 4f0b162..1e27b35 100644 (file)
@@ -1,4 +1,26 @@
 %{
 %{
+
+/*
+ *     Copyright (c) 1984-1987 by the Regents of the
+ *     University of California and by Gregory Glenn Minshall.
+ *
+ *     Permission to use, copy, modify, and distribute these
+ *     programs and their documentation for any purpose and
+ *     without fee is hereby granted, provided that this
+ *     copyright and permission appear on all copies and
+ *     supporting documentation, the name of the Regents of
+ *     the University of California not be used in advertising
+ *     or publicity pertaining to distribution of the programs
+ *     without specific prior permission, and notice be given in
+ *     supporting documentation that copying and distribution is
+ *     by permission of the Regents of the University of California
+ *     and by Gregory Glenn Minshall.  Neither the Regents of the
+ *     University of California nor Gregory Glenn Minshall make
+ *     representations about the suitability of this software
+ *     for any purpose.  It is provided "as is" without
+ *     express or implied warranty.
+ */
+
 typedef struct string {
     int
        hashval,
 typedef struct string {
     int
        hashval,
@@ -51,7 +73,7 @@ typedef struct same {
 %token <intval> MACRO_CHAR NL WHITE_SPACE
 %token <intval> ':' '=' '$' '{' '}' ';' '-' '@' '(' ')' ' ' '\t'
 %type <same> target target1 assignment assign1 actions action
 %token <intval> MACRO_CHAR NL WHITE_SPACE
 %token <intval> ':' '=' '$' '{' '}' ';' '-' '@' '(' ')' ' ' '\t'
 %type <same> target target1 assignment assign1 actions action
-%type <same> command_list command list
+%type <same> command_list list list_element
 %type <same> for_statement maybe_at_minus tokens token
 %type <same> maybe_white_space
 %type <intval> white_space macro_char
 %type <same> for_statement maybe_at_minus tokens token
 %type <same> maybe_white_space
 %type <intval> white_space macro_char
@@ -68,8 +90,7 @@ line : NL
     | target_action
     ;
 
     | target_action
     ;
 
-assignment :
-    assign1 tokens NL
+assignment : assign1 tokens NL
     {
        assign($1, $2);
     }
     {
        assign($1, $2);
     }
@@ -92,8 +113,7 @@ target_action: target actions
     }
     ;
 
     }
     ;
 
-target :
-    target1 tokens NL
+target : target1 tokens NL
     {
        $$ = add_depends($1, $2);
     }
     {
        $$ = add_depends($1, $2);
     }
@@ -112,7 +132,7 @@ target1: tokens maybe_white_space ':' maybe_white_space
 actions: action
     | actions action
     {
 actions: action
     | actions action
     {
-       $$ = same_cat($1, $2);
+       $$ = same_cat(same_cat($1, same_copy(newline)), $2);
     }
     ;
 
     }
     ;
 
@@ -129,7 +149,7 @@ action:     white_space command_list NL
 for_statement: maybe_at_minus FOR white_space token
                in tokens semi_colon
     {
 for_statement: maybe_at_minus FOR white_space token
                in tokens semi_colon
     {
-       $$ = for_statement($1, $4, expand_variables($6, 0));
+       $$ = for_statement($1, $4, ws_merge(expand_variables($6, 0)));
     }
     ;
 
     }
     ;
 
@@ -150,14 +170,22 @@ command_list: list
     }
     ;
 
     }
     ;
 
-list: command
-    | list semi_colon maybe_white_space command
+list: token
+    | list list_element
     {
     {
-       $$ = same_cat($1, same_cat(same_copy(newline), $4));
+       $$ = same_cat($1, $2);
+    }
+    | list white_space list_element
+    {
+       $$ = same_cat($1, same_cat(same_copy(blank), $3));
     }
     ;
 
     }
     ;
 
-command: tokens
+list_element: token
+    | semi_colon
+    {
+       $$ = same_copy(newline);
+    }
     ;
 
 maybe_at_minus: /* empty */
     ;
 
 maybe_at_minus: /* empty */
@@ -661,14 +689,14 @@ int       free;
        char *string = token->string->string;
        same_t *tmp = same_unlink(token);
 
        char *string = token->string->string;
        same_t *tmp = same_unlink(token);
 
-       if ((string[0] == '$') && (string[1] == '{')) {/* '}' Expand time */
+       if ((string[0] == '$') && (string[1] == '{')) { /* Expand time */
            int len = strlen(string);
 
            string[len-1] = 0;
            head = same_cat(head, expand_variables(
                        value_of(same_item(string_lookup(string+2))), 1));
            string[len-1] = '}';
            int len = strlen(string);
 
            string[len-1] = 0;
            head = same_cat(head, expand_variables(
                        value_of(same_item(string_lookup(string+2))), 1));
            string[len-1] = '}';
-       } else if (!isspace(string[0])) {
+       } else {
            head = same_cat(head, token);
        }
        token = tmp;
            head = same_cat(head, token);
        }
        token = tmp;
@@ -929,7 +957,12 @@ yylex()
            Return(c,c);
        case '\'':
        case '"':
            Return(c,c);
        case '\'':
        case '"':
-           {
+           if (bufptr != buffer) {
+               if (bufptr[-1] == '\\') {
+                   bufptr[-1] = c;
+               }
+               break;
+           } else {
                int newc;
 
                ret_token(c);
                int newc;
 
                ret_token(c);
@@ -1025,9 +1058,9 @@ do_dump()
     }
     visit_end();
 
     }
     visit_end();
 
-    printf("#targets...\n");
+    printf("\n\n#targets...\n");
     for (visit(targets, same); !visited(same); visit_next(same)) {
     for (visit(targets, same); !visited(same); visit_next(same)) {
-       printf("%s:\t", same->string->string);
+       printf("\n%s:\t", same->string->string);
        for (visit(same->depend_list, same2); !visited(same2);
                                                visit_next(same2)) {
            printf(same2->string->string);
        for (visit(same->depend_list, same2); !visited(same2);
                                                visit_next(same2)) {
            printf(same2->string->string);