[53] | 1 | /* Running commands on Amiga
|
---|
[3140] | 2 | Copyright (C) 1995-2016 Free Software Foundation, Inc.
|
---|
[53] | 3 | This file is part of GNU Make.
|
---|
| 4 |
|
---|
[503] | 5 | GNU Make is free software; you can redistribute it and/or modify it under the
|
---|
| 6 | terms of the GNU General Public License as published by the Free Software
|
---|
[1993] | 7 | Foundation; either version 3 of the License, or (at your option) any later
|
---|
| 8 | version.
|
---|
[53] | 9 |
|
---|
[503] | 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
|
---|
| 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
---|
| 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
---|
[53] | 13 |
|
---|
[503] | 14 | You should have received a copy of the GNU General Public License along with
|
---|
[1993] | 15 | this program. If not, see <http://www.gnu.org/licenses/>. */
|
---|
[53] | 16 |
|
---|
[3140] | 17 | #include "makeint.h"
|
---|
[53] | 18 | #include "variable.h"
|
---|
| 19 | #include "amiga.h"
|
---|
| 20 | #include <assert.h>
|
---|
| 21 | #include <exec/memory.h>
|
---|
| 22 | #include <dos/dostags.h>
|
---|
| 23 | #include <proto/exec.h>
|
---|
| 24 | #include <proto/dos.h>
|
---|
| 25 |
|
---|
| 26 | static const char Amiga_version[] = "$VER: Make 3.74.3 (12.05.96) \n"
|
---|
[3140] | 27 | "Amiga Port by A. Digulla (digulla@home.lake.de)";
|
---|
[53] | 28 |
|
---|
| 29 | int
|
---|
| 30 | MyExecute (char **argv)
|
---|
| 31 | {
|
---|
| 32 | char * buffer, * ptr;
|
---|
| 33 | char ** aptr;
|
---|
| 34 | int len = 0;
|
---|
| 35 | int status;
|
---|
| 36 |
|
---|
| 37 | for (aptr=argv; *aptr; aptr++)
|
---|
| 38 | {
|
---|
[3140] | 39 | len += strlen (*aptr) + 4;
|
---|
[53] | 40 | }
|
---|
| 41 |
|
---|
| 42 | buffer = AllocMem (len, MEMF_ANY);
|
---|
| 43 |
|
---|
| 44 | if (!buffer)
|
---|
[3140] | 45 | O (fatal, NILF, "MyExecute: Cannot allocate space for calling a command\n");
|
---|
[53] | 46 |
|
---|
| 47 | ptr = buffer;
|
---|
| 48 |
|
---|
| 49 | for (aptr=argv; *aptr; aptr++)
|
---|
| 50 | {
|
---|
[3140] | 51 | if (((*aptr)[0] == ';' && !(*aptr)[1]))
|
---|
| 52 | {
|
---|
| 53 | *ptr ++ = '"';
|
---|
| 54 | strcpy (ptr, *aptr);
|
---|
| 55 | ptr += strlen (ptr);
|
---|
| 56 | *ptr ++ = '"';
|
---|
| 57 | }
|
---|
| 58 | else if ((*aptr)[0] == '@' && (*aptr)[1] == '@' && !(*aptr)[2])
|
---|
| 59 | {
|
---|
| 60 | *ptr ++ = '\n';
|
---|
| 61 | continue;
|
---|
| 62 | }
|
---|
| 63 | else
|
---|
| 64 | {
|
---|
| 65 | strcpy (ptr, *aptr);
|
---|
| 66 | ptr += strlen (ptr);
|
---|
| 67 | }
|
---|
| 68 | *ptr ++ = ' ';
|
---|
| 69 | *ptr = 0;
|
---|
[53] | 70 | }
|
---|
| 71 |
|
---|
| 72 | ptr[-1] = '\n';
|
---|
| 73 |
|
---|
| 74 | status = SystemTags (buffer,
|
---|
[3140] | 75 | SYS_UserShell, TRUE,
|
---|
| 76 | TAG_END);
|
---|
[53] | 77 |
|
---|
| 78 | FreeMem (buffer, len);
|
---|
| 79 |
|
---|
[3140] | 80 | if (SetSignal (0L,0L) & SIGBREAKF_CTRL_C)
|
---|
| 81 | status = 20;
|
---|
[53] | 82 |
|
---|
| 83 | /* Warnings don't count */
|
---|
| 84 | if (status == 5)
|
---|
[3140] | 85 | status = 0;
|
---|
[53] | 86 |
|
---|
| 87 | return status;
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | char *
|
---|
| 91 | wildcard_expansion (char *wc, char *o)
|
---|
| 92 | {
|
---|
[3140] | 93 | # define PATH_SIZE 1024
|
---|
[53] | 94 | struct AnchorPath * apath;
|
---|
| 95 |
|
---|
| 96 | if ( (apath = AllocMem (sizeof (struct AnchorPath) + PATH_SIZE,
|
---|
[3140] | 97 | MEMF_CLEAR))
|
---|
| 98 | )
|
---|
[53] | 99 | {
|
---|
[3140] | 100 | apath->ap_Strlen = PATH_SIZE;
|
---|
[53] | 101 |
|
---|
[3140] | 102 | if (MatchFirst (wc, apath) == 0)
|
---|
| 103 | {
|
---|
| 104 | do
|
---|
| 105 | {
|
---|
| 106 | o = variable_buffer_output (o, apath->ap_Buf,
|
---|
| 107 | strlen (apath->ap_Buf));
|
---|
| 108 | o = variable_buffer_output (o, " ",1);
|
---|
| 109 | } while (MatchNext (apath) == 0);
|
---|
| 110 | }
|
---|
[53] | 111 |
|
---|
[3140] | 112 | MatchEnd (apath);
|
---|
| 113 | FreeMem (apath, sizeof (struct AnchorPath) + PATH_SIZE);
|
---|
[53] | 114 | }
|
---|
| 115 |
|
---|
| 116 | return o;
|
---|
| 117 | }
|
---|