summaryrefslogtreecommitdiff
path: root/pkgtools/R2pkg
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2019-10-13 19:34:13 +0000
committerrillig <rillig@pkgsrc.org>2019-10-13 19:34:13 +0000
commitfe588183e101eaeedda74edc2c73d99cea841ae1 (patch)
treefd8331b8bbce5f99df864468b173c400e4d046bc /pkgtools/R2pkg
parent03978c8455a59a862df8b1d31e1d8658a950653f (diff)
downloadpkgsrc-fe588183e101eaeedda74edc2c73d99cea841ae1.tar.gz
pkgtools/R2pkg: shorten code in read.Makefile.as.dataframe
Diffstat (limited to 'pkgtools/R2pkg')
-rw-r--r--pkgtools/R2pkg/files/R2pkg.R43
1 files changed, 8 insertions, 35 deletions
diff --git a/pkgtools/R2pkg/files/R2pkg.R b/pkgtools/R2pkg/files/R2pkg.R
index 01d0c0212f0..5c74f5261f8 100644
--- a/pkgtools/R2pkg/files/R2pkg.R
+++ b/pkgtools/R2pkg/files/R2pkg.R
@@ -1,4 +1,4 @@
-# $NetBSD: R2pkg.R,v 1.6 2019/10/13 18:13:03 rillig Exp $
+# $NetBSD: R2pkg.R,v 1.7 2019/10/13 19:34:13 rillig Exp $
#
# Copyright (c) 2014,2015,2016,2017,2018,2019
# Brook Milligan. All rights reserved.
@@ -283,44 +283,17 @@ read.Makefile.as.dataframe <- function(filename = 'Makefile.orig')
re.operator <- '[+=]+'
re.delimiter <- re.skip_blank
re.value <- re.anything
- re.optional_TODO <- '(#[[:blank:]]*TODO[[:blank:]]*:[[:blank:]]*)*'
+ re.optional_TODO <- '(?:#[[:blank:]]*TODO[[:blank:]]*:[[:blank:]]*)*'
- re.match_operator <- paste0('^',
+ re.match <- paste0('^',
re.skip_blank,
- re.optional_TODO,
+ '(',re.optional_TODO,')',
re.key,
re.skip_blank,
'(',re.operator,')',
- re.delimiter,
- re.value,
- '$')
- re.match_delimiter <- paste0('^',
- re.skip_blank,
- re.optional_TODO,
- re.key,
- re.skip_blank,
- re.operator,
'(',re.delimiter,')',
- re.value,
- '$')
- re.match_value <- paste0('^',
- re.skip_blank,
- re.optional_TODO,
- re.key,
- re.skip_blank,
- re.operator,
- re.delimiter,
'(',re.value,')',
'$')
- re.match_optional_TODO <- paste0('^',
- re.skip_blank,
- '(',re.optional_TODO,')',
- re.key,
- re.skip_blank,
- re.operator,
- re.delimiter,
- re.value,
- '$')
df <- read.file.as.dataframe(filename)
@@ -332,10 +305,10 @@ read.Makefile.as.dataframe <- function(filename = 'Makefile.orig')
df <- categorize.depends(df)
df <- categorize.buildlink(df)
- df$operator <- sub(re.match_operator,'\\2',df$line)
- df$delimiter <- sub(re.match_delimiter,'\\2',df$line)
- df$old_value <- sub(re.match_value,'\\2',df$line)
- df$old_todo <- sub(re.match_optional_TODO,'\\1',df$line)
+ 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