# -*- shell-script -*- # Debugger load SCRIPT command. # # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008, 2010, # 2011 Rocky Bernstein # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to # the Free Software Foundation, 59 Temple Place, Suite 330, Boston, # MA 02111 USA. _Dbg_help_add load \ 'load SCRIPT Read in lines of a SCRIPT for use in listing.' proc _Dbg_do_load { if (( $# != 1 )) { _Dbg_errmsg "Expecting one filename parameter, Got $Argc." return 1 } typeset filename="$1" var full_filename = $[_Dbg_resolve_expand_filename $filename] if test -n $full_filename && test -r $full_filename { # Have we already loaded in this file? for file in [$(_Dbg_filenames[@])] { if [[ $file == $full_filename ]] { _Dbg_msg "File $full_filename already loaded." return 2 } } _Dbg_readin $full_filename _Dbg_msg "File $full_filename loaded." } else { _Dbg_errmsg "Couldn't resolve or read $filename" return 3 } return 0 } (CommandList children: [ (C {(_Dbg_help_add)} {(load)} {(SQ <"load SCRIPT\n"> <"\n"> <"Read in lines of a SCRIPT for use in listing.">)} ) (FuncDef name: _Dbg_do_load body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DParen child: (ArithBinary op_id: Arith_NEqual left: (ArithWord w:{($ VSub_Pound "$#")}) right: (ArithWord w:{(Lit_Digits 1)}) ) ) terminator: ) ] action: [ (C {(_Dbg_errmsg)} {(DQ ("Expecting one filename parameter, Got ") ($ VSub_Pound "$#") (.))} ) (ControlFlow token: arg_word:{(1)}) ] spids: [-1 96] ) ] spids: [-1 113] ) (C {(typeset)} {(Lit_VarLike "filename=") (DQ ($ VSub_Number "$1"))}) (Assignment keyword: Assign_Local pairs: [ (assign_pair lhs: (LhsName name:full_filename) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(_Dbg_resolve_expand_filename)} {(DQ ($ VSub_Name "$filename"))}) ] ) left_token: spids: [128 134] ) } spids: [127] ) ] spids: [125] ) (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (C {(Lit_Other "[")} {(-n)} {($ VSub_Name "$full_filename")} {(Lit_Other "]")} ) (C {(Lit_Other "[")} {(-r)} {($ VSub_Name "$full_filename")} {(Lit_Other "]")} ) ] op_id: Op_DAmp ) terminator: ) ] action: [ (ForEach iter_name: file iter_words: [ { (BracedVarSub token: bracket_op: (WholeArray op_id:Lit_At) spids: [173 178] ) } ] do_arg_iter: False body: (DoGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Name "$file")} right: {($ VSub_Name "$full_filename")} ) ) terminator: ) ] action: [ (C {(_Dbg_msg)} { (DQ ("File ") ($ VSub_Name "$full_filename") (" already loaded.") ) } ) (ControlFlow token: arg_word: {(2)} ) ] spids: [-1 200] ) ] spids: [-1 217] ) ] spids: [182 220] ) spids: [172 180] ) (C {(_Dbg_readin)} {(DQ ($ VSub_Name "$full_filename"))}) (C {(_Dbg_msg)} {(DQ ("File ") ($ VSub_Name "$full_filename") (" loaded."))}) ] spids: [-1 159] ) ] else_action: [ (C {(_Dbg_errmsg)} {(DQ ("Couldn't resolve or read ") ($ VSub_Name "$filename"))}) (ControlFlow token: arg_word:{(3)}) ] spids: [240 256] ) (ControlFlow token: arg_word:{(0)}) ] spids: [77] ) spids: [73 76] ) ] )