2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /******************************************************************************
25 Skip commands in a script file until a certain label (declared with
26 Lab) or an EndSkip command is reached.
30 LABEL -- The label to skip to.
32 BACK -- Specify this if the label appears before the Skip statement
51 09.03.2009 OTigreat 41.2 Let's find Lab even after an empty line
52 14.01.2000 SDuvan 41.1 Implemented
54 ******************************************************************************/
56 #include <proto/dos.h>
58 #include <dos/dosextens.h>
59 #include <dos/rdargs.h>
60 #include <dos_commanderrors.h>
61 #include <dos/stdio.h>
63 #include <aros/shcommands.h>
66 AROS_SHA(STRPTR
, , LABEL
, , NULL
),
67 AROS_SHA(BOOL
, , BACK
, /S
, FALSE
))
71 struct CommandLineInterface
*cli
= Cli();
72 BOOL labelFound
= FALSE
;
75 if(cli
== NULL
|| cli
->cli_CurrentInput
== cli
->cli_StandardInput
)
77 PrintFault(ERROR_SCRIPT_ONLY
, "Skip");
83 char buffer
[256], a
= 0;
87 SelectInput(cli
->cli_CurrentInput
);
92 Seek(Input(), 0, OFFSET_BEGINNING
);
97 status
= ReadItem(buffer
, sizeof(buffer
), NULL
);
99 if (status
== ITEM_ERROR
)
104 if (status
== ITEM_NOTHING
)
106 if (a
== ENDSTREAMCH
)
112 switch (FindArg("LAB,ENDSKIP", buffer
))
115 if (SHArg(LABEL
) != NULL
)
117 ReadItem(buffer
, sizeof(buffer
), NULL
);
119 if (FindArg(SHArg(LABEL
), buffer
) == 0)
132 /* Skip to the next line */
136 } while (a
!= '\n' && a
!= ENDSTREAMCH
);
140 if (!labelFound
&& SHArg(LABEL
) != NULL
)
142 SetIoErr(ERROR_OBJECT_NOT_FOUND
);
143 PrintFault(ERROR_OBJECT_NOT_FOUND
, "Skip");