From 0ebf91be52c9197fc4f7ae200a6f0765905b751d Mon Sep 17 00:00:00 2001 From: cuz Date: Sun, 25 Jun 2000 14:08:36 +0000 Subject: [PATCH] Check for duplicate files in an argument list and print a warning git-svn-id: svn://svn.cc65.org/cc65/trunk@129 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cl65/main.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index a0cac2250..a62d461ec 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -250,10 +250,26 @@ static void CmdAddFile (CmdDesc* Cmd, const char* File) Cmd->FileMax = NewMax; } - /* Add a copy of the file name, allow a NULL pointer */ + /* If the file name is not NULL (which is legal and is used to terminate + * the file list), check if the file name does already exist in the file + * list and print a warning if so. Regardless of the search result, add + * the file. + */ if (File) { + unsigned I; + for (I = 0; I < Cmd->FileCount; ++I) { + if (strcmp (Cmd->Files[I], File) == 0) { + /* Duplicate file */ + Warning ("Duplicate file in argument list: `%s'", File); + /* No need to search further */ + break; + } + } + + /* Add the file */ Cmd->Files [Cmd->FileCount++] = xstrdup (File); } else { + /* Add a NULL pointer */ Cmd->Files [Cmd->FileCount++] = 0; } } -- 2.39.5