/* BEGIN INCLUDE FILE gcos_canonicalizer.incl.pl1 (Wardd Multics) 06/21/81 1435.3 mst Sun */ canonicalizer: proc ( input_string_ptr , initial_input_characters , output_card_ptr , initial_output_columns ); /* NOTE: a copy of this internal procedure exists also in gcos_card_utility_. The initialization is different, but the canonicalization code is the same. Any changes should be made to both copies, if appropriate. */ dcl initial_input_characters fixed bin(21) parm; dcl initial_output_columns fixed bin(24)parm; dcl input_string_ptr ptr parm; dcl output_card_ptr ptr parm; next_input_character, next_output_column = 1; remaining_input_characters = initial_input_characters; remaining_output_columns = initial_output_columns; more_backspaces, more_tabs = "1"b; /* we want to look for backspaces and tabs at the start */ if substr (input_string, remaining_input_characters, 1) = ascii_newline /* if last char is a newline */ then remaining_input_characters = remaining_input_characters - 1; /* then get rid of it */ /* choose the set of tabs to use for this card */ if substr (input_string, 1, 1) = "$" then if length (input_string)>1 then if (substr (input_string, 2, 1) = TAB) | (substr (input_string, 2, 1) = SP) then do; tab_ptr = addr (tab (0)); goto selected; end; tab_ptr = addr (tab (nondollar_canon_index)); /* tabs for the nondollar cards in this activity */ selected: ; /* MAIN LOOP. FILL UP OUTPUT CARD */ do while (remaining_output_columns > 0); /* keep going while there is any room on output card */ if more_backspaces then do; /* if there MIGHT be more backspaces */ /* then look for one */ next_backspace = index (substr (input_string, next_input_character, remaining_input_characters), ascii_backspace); if next_backspace = 0 then more_backspaces = "0"b; /* if none found, remember not to look again */ end; if more_tabs then /* if there MIGHT be more tabs */ find_next_tab: do; /* then look for one */ next_tab = index (substr (input_string, next_input_character, remaining_input_characters), TAB); if next_tab = 0 then more_tabs = "0"b; /* if none found, remember not to look again */ end; if more_backspaces then do; /* if we found a backspace */ /* see if it is in a legal position */ /* maybe sometime allow backspaces to be in places other than immediately following tabs, but for now, it's an error */ if ^more_tabs | next_backspace ^= next_tab+1 then do; code = 0; err_msg = "canonicalizer: backspace (s) not following a tab in line from ^a:^/" || input_string; goto file_error; end; end; if more_tabs then do; /* if we found a tab, we want to move the characters before it */ /* to the output card, and fill with blanks to next tab stop */ character_count = min ( /* compute the number of characters */ next_tab - 1, /* before the tab */ remaining_output_columns); /* but not more than there's room for on output card */ first_blank = next_output_column + character_count; do i = 1 to hbound (tabstop, 1) /* look for a tabstop */ while (tabstop (i) <= first_blank); /* that's past the characters */ /* if it's in the column immediately after the characters, then go to next one, the way a typewriter will */ end; if i <= hbound (tabstop, 1) then /* if we found one */ blank_count = min ( /* compute the number of blanks */ tabstop (i) - first_blank, /* needed to get there */ remaining_output_columns); /* but not more than there's room for on output card */ else /* if no more tabstops, replace tab with one blank */ blank_count = min (1, remaining_output_columns); end; else do; /* if there are no more tabs, we want to move the rest of the input characters to the output card, and fill the rest of it with blanks */ character_count = min ( /* compute rest of characters to move */ remaining_input_characters, /* all the rest, since no more tabs */ remaining_output_columns); /* but not more than there's room for on output card */ blank_count = max (0, /* compute blanks needed to fill rest of card */ remaining_output_columns - remaining_input_characters); end; if character_count > 0 then do; /* move characters to output card, if there are any */ substr (output_card, next_output_column, character_count) = substr (input_string, next_input_character, character_count); remaining_input_characters = remaining_input_characters - character_count; next_input_character = next_input_character + character_count; remaining_output_columns = remaining_output_columns - character_count; next_output_column = next_output_column + character_count; end; if blank_count > 0 then do; /* fill with blanks, if any */ substr (output_card, next_output_column, blank_count) = ""; remaining_output_columns = remaining_output_columns - blank_count; next_output_column = next_output_column + blank_count; end; if more_tabs then do; /* move past tab in input string */ remaining_input_characters = remaining_input_characters - 1; next_input_character = next_input_character + 1; end; if more_backspaces then do; /* if we found a backspace, we will: 1) see if there's more than one of them, and 2) move back that many columns, deleting whatever is there, (probably only blanks ) */ do i = next_input_character to initial_input_characters while (substr (input_string, i, 1) = ascii_backspace); end; character_count = i - next_input_character; /* count backspace characters */ backspace_count = min (character_count, /* count columns to backspace */ next_output_column - 1); /* but don't backspace past beginning of card */ /* skip over input backspace characters */ remaining_input_characters = remaining_input_characters - character_count; next_input_character = next_input_character + character_count; /* backspace on output card */ remaining_output_columns = remaining_output_columns + backspace_count; next_output_column = next_output_column - backspace_count; end; end; /* WE FALL THRU HERE WHEN remaining_output_columns BECOMES ZERO */ if remaining_input_characters > 0 then /* if input left over */ if ^gcos_ext_stat_$save_data.truncate then do; /* and -truncate not given, complain */ code = 0; err_num = initial_input_characters; err_msg = "line from ^a is too long (^d characters)^/" || input_string; if ^gcos_ext_stat_$save_data.continue then /* this is a nonfatal error */ goto file_error; if ^gcos_ext_stat_$save_data.brief then /* complain unless told to be quiet */ call ioa_ (err_msg, current_file.pathname, err_num); end; return; dcl backspace_count fixed bin(24); dcl blank_count fixed bin(24); dcl character_count fixed bin(24); dcl first_blank fixed bin(24); dcl input_string char (initial_input_characters) based (input_string_ptr); dcl more_backspaces bit(1) aligned; dcl more_tabs bit(1)aligned; dcl next_backspace fixed bin(24) /* relative to next_input_character */; dcl next_input_character fixed bin(24); dcl next_output_column fixed bin(24); dcl next_tab fixed bin(24) /* relative to next_input_character */; dcl output_card char (initial_output_columns) based (output_card_ptr); dcl remaining_input_characters fixed bin(24); dcl remaining_output_columns fixed bin(24); dcl SP char(1)static int options(constant)init(" "); dcl TAB char(1)static int options(constant)init(" "); dcl tabstop (10) fixed bin(24)based (tab_ptr); dcl tab_ptr ptr; end canonicalizer; /* END INCLUDE FILE gcos_canonicalizer.incl.pl1 */ */ ----------------------------------------------------------- Historical Background This edition of the Multics software materials and documentation is provided and donated to Massachusetts Institute of Technology by Group Bull including Bull HN Information Systems Inc. as a contribution to computer science knowledge. This donation is made also to give evidence of the common contributions of Massachusetts Institute of Technology, Bell Laboratories, General Electric, Honeywell Information Systems Inc., Honeywell Bull Inc., Groupe Bull and Bull HN Information Systems Inc. to the development of this operating system. Multics development was initiated by Massachusetts Institute of Technology Project MAC (1963-1970), renamed the MIT Laboratory for Computer Science and Artificial Intelligence in the mid 1970s, under the leadership of Professor Fernando Jose Corbato. Users consider that Multics provided the best software architecture for managing computer hardware properly and for executing programs. Many subsequent operating systems incorporated Multics principles. Multics was distributed in 1975 to 2000 by Group Bull in Europe , and in the U.S. by Bull HN Information Systems Inc., as successor in interest by change in name only to Honeywell Bull Inc. and Honeywell Information Systems Inc. . ----------------------------------------------------------- Permission to use, copy, modify, and distribute these programs and their documentation for any purpose and without fee is hereby granted,provided that the below copyright notice and historical background appear in all copies and that both the copyright notice and historical background and this permission notice appear in supporting documentation, and that the names of MIT, HIS, Bull or Bull HN not be used in advertising or publicity pertaining to distribution of the programs without specific prior written permission. Copyright 1972 by Massachusetts Institute of Technology and Honeywell Information Systems Inc. Copyright 2006 by Bull HN Information Systems Inc. Copyright 2006 by Bull SAS All Rights Reserved */