pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/pkgtools/R2pkg/files



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sat Oct 19 13:55:09 UTC 2019

Modified Files:
        pkgsrc/pkgtools/R2pkg/files: R2pkg.R R2pkg_test.R

Log Message:
pkgtools/R2pkg: code cleanup


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 pkgsrc/pkgtools/R2pkg/files/R2pkg.R
cvs rdiff -u -r1.12 -r1.13 pkgsrc/pkgtools/R2pkg/files/R2pkg_test.R

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/R2pkg/files/R2pkg.R
diff -u pkgsrc/pkgtools/R2pkg/files/R2pkg.R:1.17 pkgsrc/pkgtools/R2pkg/files/R2pkg.R:1.18
--- pkgsrc/pkgtools/R2pkg/files/R2pkg.R:1.17    Sat Oct 19 13:37:00 2019
+++ pkgsrc/pkgtools/R2pkg/files/R2pkg.R Sat Oct 19 13:55:09 2019
@@ -1,4 +1,4 @@
-# $NetBSD: R2pkg.R,v 1.17 2019/10/19 13:37:00 rillig Exp $
+# $NetBSD: R2pkg.R,v 1.18 2019/10/19 13:55:09 rillig Exp $
 #
 # Copyright (c) 2014,2015,2016,2017,2018,2019
 #      Brook Milligan.  All rights reserved.
@@ -264,48 +264,32 @@ fix.continued.lines <- function(df,line=
 
 read.Makefile.as.dataframe <- function(filename = 'Makefile.orig')
 {
-  # message('===> read.Makefile.as.dataframe():')
-
-  re.skip_blank <- '[[:blank:]]*'
-  re.blank <- '[[:blank:]]+'
-  re.anything <- '.*'
-
-  re.key <- '[^+=[:blank:]]+'
-  re.operator <- '[+=]+'
-  re.delimiter <- re.skip_blank
-  re.value <- re.anything
-  re.optional_TODO <- '(?:#[[:blank:]]*TODO[[:blank:]]*:[[:blank:]]*)*'
-
-  re.match <- paste0('^',
-    re.skip_blank,
-    '(',re.optional_TODO,')',
-    re.key,
-    re.skip_blank,
-    '(',re.operator,')',
-    '(',re.delimiter,')',
-    '(',re.value,')',
+  re_varassign <- paste0(
+    '^',
+    ' *',
+    '(', '(?:#[\t ]*TODO[\t ]*:[\t ]*)*',')',  # comment
+    '[^+=[:blank:]]+',  # varname
+    '[\t ]*',
+    '(', '[+=]+',')',  # operator
+    '(', '[\t ]*',')',  # delimiter
+    '(', '.*',')',
     '$')
 
   df <- read.file.as.dataframe(filename)
 
   df$order <- 1:nrow(df)
-  df$category <- NA
+  df$category <- NA  # for DEPENDS lines
 
   df <- categorize.key_value(df)
   df <- fix.continued.lines(df)
   df <- categorize.depends(df)
   df <- categorize.buildlink(df)
 
-  df$operator <- sub(re.match, '\\2', df$line)
-  df$delimiter <- sub(re.match, '\\3', df$line)
-  df$old_value <- sub(re.match, '\\4', df$line)
-  df$old_todo <- sub(re.match, '\\1', df$line)
-
-  df$operator[!df$key_value] <- NA
-  df$delimiter[!df$key_value] <- NA
-  df$old_value[!df$key_value] <- NA
-  df$old_todo[!df$key_value] <- NA
-
+  va <- df$key_value
+  df$old_todo[va] <- sub(re_varassign, '\\1', df$line[va])
+  df$operator[va] <- sub(re_varassign, '\\2', df$line[va])
+  df$delimiter[va] <- sub(re_varassign, '\\3', df$line[va])
+  df$old_value[va] <- sub(re_varassign, '\\4', df$line[va])
   df
 }
 

Index: pkgsrc/pkgtools/R2pkg/files/R2pkg_test.R
diff -u pkgsrc/pkgtools/R2pkg/files/R2pkg_test.R:1.12 pkgsrc/pkgtools/R2pkg/files/R2pkg_test.R:1.13
--- pkgsrc/pkgtools/R2pkg/files/R2pkg_test.R:1.12       Sat Oct 19 13:37:00 2019
+++ pkgsrc/pkgtools/R2pkg/files/R2pkg_test.R    Sat Oct 19 13:55:09 2019
@@ -1,4 +1,4 @@
-# $NetBSD: R2pkg_test.R,v 1.12 2019/10/19 13:37:00 rillig Exp $
+# $NetBSD: R2pkg_test.R,v 1.13 2019/10/19 13:55:09 rillig Exp $
 #
 # Copyright (c) 2019
 #      Roland Illig.  All rights reserved.
@@ -213,13 +213,13 @@ test_that('read.Makefile.as.dataframe', 
         '4 .include "other.mk"     4       NA     FALSE <NA>   FALSE         FALSE',
         '5               .if 0     5       NA     FALSE <NA>   FALSE         FALSE',
         '6              .endif     6       NA     FALSE <NA>   FALSE         FALSE',
-        '  operator delimiter old_value old_todo',
-        '1     <NA>      <NA>      <NA>     <NA>',
-        '2        =               value         ',
-        '3     <NA>      <NA>      <NA>     <NA>',
-        '4     <NA>      <NA>      <NA>     <NA>',
-        '5     <NA>      <NA>      <NA>     <NA>',
-        '6     <NA>      <NA>      <NA>     <NA>')
+        '  old_todo operator delimiter old_value',
+        '1     <NA>     <NA>      <NA>      <NA>',
+        '2                 =               value',
+        '3     <NA>     <NA>      <NA>      <NA>',
+        '4     <NA>     <NA>      <NA>      <NA>',
+        '5     <NA>     <NA>      <NA>      <NA>',
+        '6     <NA>     <NA>      <NA>      <NA>')
 })
 
 test_that('read.file.as.list can read an empty file', {



Home | Main Index | Thread Index | Old Index