1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
|
$EPIC: expansions,v 1.1 2003/05/29 23:09:03 jnelson Exp $
$-expansion and Quoting Hell
Whenever you give epic a string of text, epic will usually run it through
the "expander" before it uses it. The expander has four main jobs:
1) Substitute $-expandos with whatever they evaluate to
2) Remove any \c sequences (c is any character) (**** SEE BELOW ****)
3) Find the start of the "next" command in a command set.
4) Determine if a numeric expando is used in the text.
The following places use the expander:
* alias.c prepare_alias_call
* To expand "default" values in argument list, eg
/alias oof (var1 default "$ooga") {...}
* commands.c parse_line (**** SEE BELOW ****)
* To extract and expand the first command from a block of commands
prior to execution; to determine if the command uses a numeric
expando and to append $* if it does not, eg
/alias oof {echo $ooga;echo hi}
/alias booya msg
* expr.c next_unit (SETUP_IMPLIED)
* To expand the variable name on the left hand side of an
implied assignment, eg
@ $ooga += 3
* expr.c next_unit ([...] handling)
* To expand the inside of [...] operator in an expression which
starts with $ but is not a numeric expando, eg
@ var = [$ooga]
* expr.c next_unit ([...] handling)
* To expand the inside of [...] operator that contains a $ or \
character, eg
@ var = [one two $ooga my shoe]
@ var = [one two \three four]
* expr.c next_unit (pre/post in/decrement operator)
* To expand the variable name operand of the pre or post increment
or decrement operators, eg
@ $ooga++
@ --$ooga
* expr.c next_unit (= operator handling)
* To expand the variable name on the left hand side of a straight
assignment, eg
@ $ooga = 3
* expr.c alias_special_char
* To expand the inside of the width qualifier following a $, eg
$[$ooga]var1
* expr.c alias_special_char
* To expand the inside of $(...) (``indirect'') expando, eg
$($ooga)
* expr2.c get_raw_token (NEW MATH PARSER)
* To convert an operand that is available as an "LVAL" when it is
needed to be used in a "RAW" context, eg
@ var1 = $ooga
* expr2.c get_token_expanded (NEW MATH PARSER)
* To convert an operand that is available as a "RAW" value when it
is needed to be used in an "EXPANDED" context, eg
@ var1 = [$ooga]
* functions.c call_function
* To expand the argument list contained within parenthesis to a
function being called, eg
@ func($ooga)
* functions.c function_cparse ($cparse())
* To expand the resulting string after the cparse substitutions,
for BitchX compatability, eg
/echo $cparse("one two" buckle my $1 shoes $ooga)
* hook.c do_hook
* To expand the inside of a flexible hook before pattern matching, eg
/on msg '$ooga *' {...}
* if.c fe
* To expand the word list argument to the /FE command, eg
/fe ($ooga) {...}
* if.c for_fe_cmd
* To expand the word list argument to the /FOR I IN (...) command, eg
/for i in ($ooga) {...}
* if.c switchcmd
* To expand the control string argument to the /SWITCH command, eg
/switch ($ooga) {....}
* if.c switcmd
* To expand the matching string argument to the /SWITCH command, eg
/switch ($*) {($ooga) {...}}
* if.c repeatcmd
* To expand the number-iterations argument to the /REPEAT command, eg
/repeat $ooga ....
* input.c update_input
* To expand the value of /set input_prompt prior to display, eg
/set input_prompt ${ooga}>
* ircaux.c remove_brackets
* To expand the inside of a variable array qualifier, eg
$var1[$ooga]
* log.c add_to_log
* To rewrite text sent to a log before writing it, eg
/set log_rewrite $ooga $1-
/log new rewrite "$ooga $1-"
* numbers.c banner
* To expand /set banner prior to display when /set banner_expand on, eg
/set banner $ooga
/set banner_expand on
* output.c vsay
* To expand /set banner prior to display when /set banner_expand on, eg
/set banner $ooga
/set banner_expand on
* queue.c queuecmd
* To expand the command bodies at registration time if -expand_now
is used, eg
/queue -expand_now {$ooga}
* screen.c add_to_window
* To rewrite text sent to a window before displaying it, eg
/set output_rewrite $ooga $1-
* status.c make_status
* To expand the status bar after substitution but before displaying
it when /set status_does_expandos on, eg
/set status_user1 $ooga
/set status_does_expandos on
==============================================================================
The "dequoter" is the function that removes \'s from a text string. It is the
place that most commonly causes ``quoting hell''. Each time a function is
passed through the "dequoter", another level of \'s are removed.
The "dequoter" is malloc_strcat_ues_c, and it is called by the following:
* expr.c expand_alias
* To copy portions of the original string that are not part of
a $-expando, contained withing parenthesis, or braces,
* window.c window_channel
* To convert \" to " from the argument to /window channel so you
may join channels with quotes in them, eg
/window channel "#one\"two"
/window channel #foobar "key\"withquote"
==============================================================================
The "Evaluator" is the function that runs a block of commands that you give it.
It is the basis of the /eval command and every command you run in the language
goes through it at least once. The evaluator may pass the commands through
expand_alias, which means support for {}s, semicolons between commands, and
$-expansion. The evaluator may just treat the entire thing as one big command
however. The caller sets a flag to decide this
The "evaluator" is parse_line, and it is called by the following:
* alias.c parse_line_alias_special
* To run a command alias's block of commands.
* Full expansion handling
* $* is passed in from above
* commands.c do_defered_commands
* To run commands that were /DEFERed previously
* Full expansion handling
* $* is saved from when /DEFER was registered
* commands.c xevalcmd
* To run a command through the evaluator a second time, possibly
in a different window or server context.
* Full expansion handling (could result in double expansion)
* $* is passed in from above
* commands.c evalcmd
* To run a command through the evaluator a second time
* Full expansion handling (could result in double expansion)
* $* is passed in from above
* commands.c loader_std
* To run one command from within a /LOADed script
* Full expansion if /SET INPUT_ALIASES is ON (usually not though)
* Full expansion if /LOAD -ARGS filename ... was used
* $* is [] if /LOAD -ARGS is not used.
* commands.c loader_pf
* To run an entire pre-formatted block of commands within a script
* Full expansion handling
* $* is [] if /LOAD -ARGS is not used.
* commands.c redirect
* To run commands to watch for data sent to server
* Full expansion handling (could result in double expansion)
* $* is passed in from above.
* commands.c sendlinecmd
* To run commands unconditionally as if from the command line
* Full expansion if /SET INPUT_ALIASES is ON (usually not though)
* $* is [] in all cases.
* commands.c waitcmd (/WAIT FOR ....)
* To run commands to watch for data sent to server in
* Full expansion handling (could result in double expansion)
* $* is passed in from above
* commands.c send_text
* To run the "AWAY" command or alias when sending a message from
the input line and when away and when /SET AUTO_UNMARK_AWAY is on.
* Full expansion handling (nothing to expand, however)
* $* is [] in all cases
* commands.c eval_inputlist
* To run commands passed to /INPUT "prompt" <commands>
* Full expansion handling (could result in double expansion)
* $* is saved from when the /input prompt was registered
* commands.c parse_line
* To run the insides of {...} blocks passed to parse_line.
* Full expansion ({...} are protected; no double expansion)
* $* is passed in from above.
* exec.c handle_fieldesc
* To run the commands of /exec -line, -error, -linepart, -errorpart,
or /exec -end.
* Full expansion (syntax forces use of {}s, so no double expansion)
* $* is provided on the fly.
* exec.c cleanup_dead_processes
* To run the commands of /wait %proc -cmd {...}
* Full expansion (could result in double expansion)
* $* is provided on the fly.
* expr.c next_unit
* To run the inside of the {...} operator as a function.
* Full expansion ({} is protected; no double expansion)
* $* is passed in from above.
* hook.c do_hook
* To run the hook command body
* Full expansion (could result in double expansion)
* $* is provided on the fly.
* if.c ifcmd
* To run commands in an /IF decision block
* Full expansion (syntax usually requires {}, so no double expansion)
* $* is passed in from above
* if.c docmd
* To run commands in a /DO {...} (...) loop block
* Full expansion (syntax requires {}, so no double expansion)
* $* is passed in from above
* if.c docmd
* To run commands in a /DO .... command block
* Full expansion (double expansion if {}s are not used)
* $* is passed in from above
* if.c whilecmd
* To run commands in a /WHILE (...) loop block
* Full expansion (double expansion if {}s are not used)
* $* is passed in from above
* if.c foreach
* To run commands in a /FOREACH head var {...} loop block
* Full expansion (syntax requires {}, so no double expansion)
* $* is passed in from above
* if.c fe
* To run commands in a /FE loop block
* Full expansion (syntax requires {}, so no double expansion)
* $* is passed in from above
* if.c for_next_cmd
* To run commands in a /FOR var FROM start TO end {...} loop block
* Full expansion (syntax requires {}, so no double expansion)
* $* is passed in from above
* if.c for_fe_cmd
* To run commands in a /FOR var IN (list) {...} loop block
* Full expansion (syntax requires {}, so no double expansion)
* $* is passed in from above
* if.c forcmd
* To run commands in a /FOR (...,<expr>,...) {...} loop block
* To run prelim and loop iteration commands in above.
* Full expansion (syntax requires a {}, so no double expansion)
* $* is passed in from above
* if.c switchmd
* To run commands in a /SWITCH body
* Full expansion (syntax requires {} so no double expansion)
* $* is passed in from above
* if.c repeatcmd
* To run commands to /REPEAT
* Full expansion (Double expansion if {} is not used)
* $* is passed in from above
* input.c send_line (key binding)
* To run the command in the input prompt
* Full expansion depends on /SET INPUT_ALIASES (normally off)
* $* is [] in all cases
* input.c parse_text (key binding)
* Runs the command argument to the binding, eg
/bind ^X parse_command CMD ooga booga
* Full expansion (double expansion if {} is not used argument cmds)
* $* is [] in all cases
* keys.c key_exec
* Runs an alias that is associated with a key binding
* Full expansion (double expansion if {} was not used to create bind)
* $* is [] in all cases.
* perl.c XS_cmd
* Runs a command passed in from perl as if it were executed at
the input prompt with /SET INPUT_ALIASES OFF
* No expansion (naturally)
* $* is irrelevant.
* perl.c XS_eval
* Runs a command passed in from perl as if it were executed at
the input prompt with /SET INPUT_ALIASES ON
* Full expansion
* $* is [] in every case
* queue.c run_queue
* Runs a queued command when the queue itself is run
* Full expansion (may have previously been expanded!)
* $* is saved from when the command was put into the queue.
* screen.c do_screens
* Runs a command from standard input when in "dumb mode"
* Expansion depends on /SET INPUT_ALIASES (usually off)
* $* is [] in every case
* server.c check_server_wait
* Runs a command registered with /WAIT -cmd ...
* Full expansion (double expansion if {} is not used)
* $* is [] in every case
* tcl.c Tcl_epicCmd
* Runs a command passed in from the tcl commands "cmd" or "eval"
as in the perl case.
* Expansion depends on the command (see perl case)
* $* is [] in every case
* timer.c ExecuteTimers
* Runs commands scheduled for later execution with /TIMER time ...
* Full expansion (double expansion if {} is not used)
* $* is saved from when the command was scheduled
* who.c whoreply
* Runs commands from /WHO -LINE {....}
* Full expansion (syntax requires {}, so no double expansion)
* $* is provided on the fly.
* who.c whoend
* Runs commands from /WHO -END {....}
* Full expansion (syntax requires {}, so no double expansion)
* $* is provided on the fly.
* who.c fake_who_end
* Runs commands from /WHO -END {....}
* Full expansion (syntax requires {}, so no double expansion)
* $* is provided on the fly.
* who.c userhost_cmd_returned
* Runs commands from /USERHOST <nicks> -CMD ....
* Full expansion (double expansion if {} is not used)
* $* is provided on the fly.
#end of file
|