From ae19d5c68b9ec6a886826d8f9389c7f18b582546 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Sun, 5 Sep 2021 22:24:19 -0300 Subject: [PATCH] as31: init at 2.3.1 --- .../compilers/as31/0000-getline-break.patch | 24 +++++++++++ pkgs/development/compilers/as31/default.nix | 43 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 69 insertions(+) create mode 100644 pkgs/development/compilers/as31/0000-getline-break.patch create mode 100644 pkgs/development/compilers/as31/default.nix diff --git a/pkgs/development/compilers/as31/0000-getline-break.patch b/pkgs/development/compilers/as31/0000-getline-break.patch new file mode 100644 index 000000000000..c53f6587f8ad --- /dev/null +++ b/pkgs/development/compilers/as31/0000-getline-break.patch @@ -0,0 +1,24 @@ +diff --git old/as31/run.c new/as31/run.c +index 28c5317..9e5263b 100644 +--- old/as31/run.c ++++ new/as31/run.c +@@ -113,7 +113,8 @@ int run_as31(const char *infile, int lst, int use_stdout, + } + + while (!feof(finPre)) { +- getline(&lineBuffer,&sizeBuf,finPre); ++ if (getline(&lineBuffer,&sizeBuf,finPre) == -1) ++ break; + if ((includePtr=strstr(lineBuffer,INC_CMD))) { + includePtr=includePtr+strlen(INC_CMD); + while ((*includePtr==' ')|| //move includePtr to filename +@@ -138,7 +139,8 @@ int run_as31(const char *infile, int lst, int use_stdout, + mesg_f("Cannot open include file: %s\n",includePtr); + } else { + while (!feof(includeFile)) { +- getline(&incLineBuffer,&incSizeBuf,includeFile); ++ if (getline(&incLineBuffer,&incSizeBuf,includeFile) == -1) ++ break; + fprintf(fin,"%s",incLineBuffer); + if (strlen(incLineBuffer)) { + incLineCount++; diff --git a/pkgs/development/compilers/as31/default.nix b/pkgs/development/compilers/as31/default.nix new file mode 100644 index 000000000000..c76b8a03312e --- /dev/null +++ b/pkgs/development/compilers/as31/default.nix @@ -0,0 +1,43 @@ +{ lib +, stdenv +, fetchurl +, bison +}: + +stdenv.mkDerivation rec { + pname = "as31"; + version = "2.3.1"; + + src = fetchurl { + url = "http://wiki.erazor-zone.de/_media/wiki:projects:linux:as31:${pname}-${version}.tar.gz"; + name = "${pname}-${version}.tar.gz"; + hash = "sha256-zSEyWHFon5nyq717Mpmdv1XZ5Hz0e8ZABqsP8M83c1U="; + }; + + patches = [ + # Check return value of getline in run.c + ./0000-getline-break.patch + ]; + + postPatch = '' + # parser.c is generated from parser.y; it is better to generate it via bison + # instead of using the prebuilt one, especially in x86_64 + rm -f as31/parser.c + ''; + + preConfigure = '' + chmod +x configure + ''; + + nativeBuildInputs = [ + bison + ]; + + meta = with lib; { + homepage = "http://wiki.erazor-zone.de/wiki:projects:linux:as31"; + description = "An 8031/8051 assembler"; + license = licenses.gpl2Plus; + maintainers = with maintainers; [ AndersonTorres ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5ee1d7976001..a9321c3b51be 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10822,6 +10822,8 @@ with pkgs; asciigraph = callPackage ../tools/text/asciigraph { }; + as31 = callPackage ../development/compilers/as31 { }; + asn1c = callPackage ../development/compilers/asn1c { }; aspectj = callPackage ../development/compilers/aspectj { };