m4

GNU M4: Define a rule that matches text, and operates on that matched text?

南楼画角 提交于 2019-12-11 06:33:08
问题 Suppose I have: File: [x] And I would like to define m4 macro: define(`\[.*\]`, ...) Question: Is this possible and how does one do it? 回答1: It isn't possible as you can see in manual of m4: 3.1 Macro names A name is any sequence of letters, digits, and the character ‘_’ (underscore), where the first character is not a digit. m4 will use the longest such sequence found in the input. If a name has a macro definition, it will be subject to macro expansion (see Macros). Names are case-sensitive.

GNU M4: expand bracketed text?

匆匆过客 提交于 2019-12-11 06:32:43
问题 If I run: define(`[x]`,`y') [x] =>[x] Nothing happens.. Is there a way to expand brackets in M4? 回答1: If the name of the macro that you have defined contains non-alphanumeric characters the only way to expand its content is by using the defn() built-in macro: define(`[x]',`y') defn(`[x]') => y 来源: https://stackoverflow.com/questions/57205431/gnu-m4-expand-bracketed-text

Build m4, autoconf, automake, libtool on unix

拟墨画扇 提交于 2019-12-10 19:59:49
问题 I'm trying to setup PHP, apache environment on HP-UX server. While install i'm using usual commands of "./configur, make, make install". Here when I'm trying to install PCRE I got an error like follows. CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/bash /home/ubuntu/softwares/m4-1.4.17/build-aux/missing aclocal-1.14 -I m4 /home/ubuntu/softwares/m4-1.4.17/build-aux/missing: line 81: aclocal-1.14: command not found WARNING: 'aclocal-1.14' is missing on your system. You should only need it if you

Pre-Processing using m4

♀尐吖头ヾ 提交于 2019-12-08 02:46:47
问题 I am writing a pre-processor for Free-Pascal (Course Work) using m4. I was reading the thread at stackoverflow here and from there reached a blog which essentially shows the basic usage of m4 for pre-processing for C . The blogger uses a testing C file test.c.m4 like this: #include define(`DEF', `3') int main(int argc, char *argv[]) { printf("%d\n", DEF); return 0; } and generates processed C file like this using m4 , which is fine. $ m4 test.c.m4 > test.c $ cat test.c #include <stdio.h> int

“Help” string variable substitution for “configure --help”

点点圈 提交于 2019-12-07 11:36:25
问题 I have a string that I want to use multiple times for the output of configure --help . So I try doing something like this in configure.ac : AC_ARG_ENABLE([foobar], AS_HELP_STRING([--enable-foobar], [$foobar_help_str])) But no expansion or substitution is done, so the output is just $foobar_help_str . 回答1: Define the string as an M4 macro: m4_define([FOOBAR_HELP_STR], [Turn on the foobar features]) AC_ARG_ENABLE([foobar], [AS_HELP_STRING([--enable-foobar], FOOBAR_HELP_STR)]) 回答2: FYI, if you

Using m4 to convert a string to ASCII codepoints

百般思念 提交于 2019-12-06 09:52:00
This should be possible, but as I am a novice with m4, I'm not sure how to go about it, or how to write an algorithm to do so (in m4). edit: Just solved it, anyway for future reference, I have a series of characters, they need to be translated to their equivalent ASCII code points, e.g. ascii(-{COLON}-, -{:}-) => #define TKN_COLON 58 For the benefit of others interested in a pure m4 implementation I've managed to create the following conversion macro. It has to meddle with the quoting characters to support normal m4 quote chars. It could be simplified a bit if that isn't important. changequote

Pre-Processing using m4

走远了吗. 提交于 2019-12-06 08:17:10
I am writing a pre-processor for Free-Pascal (Course Work) using m4 . I was reading the thread at stackoverflow here and from there reached a blog which essentially shows the basic usage of m4 for pre-processing for C . The blogger uses a testing C file test.c.m4 like this: #include define(`DEF', `3') int main(int argc, char *argv[]) { printf("%d\n", DEF); return 0; } and generates processed C file like this using m4 , which is fine. $ m4 test.c.m4 > test.c $ cat test.c #include <stdio.h> int main(int argc, char *argv[]) { printf("%dn", 3); return 0; } My doubts are: 1. The programmer will

M4 eval precision

為{幸葍}努か 提交于 2019-12-06 06:08:42
I'm trying to use M4 macros to generate css files. I'm willing to enter my values in px and do simple math using eval() to get results in em. Unfortunatly I didn't find how to get floats. define(`FONTSIZE', `13')dnl define(`LINEHEIGHT', `17')dnl .content {padding : eval(LINEHEIGHT / FONTSIZE)em} >>> m4 style.css.m4 >>> .content {padding : 1em} Any ideas? Thanks! For your particular purpose the expression may become something like eval(LINEHEIGHT/FONTSIZE).substr(eval(((LINEHEIGHT%FONTSIZE)*1000)/FONTSIZE + 1000),1) (of course, use the power of 10 that meets your precision requirements) This is

My custom selinux policies seem to be ignored by android system

亡梦爱人 提交于 2019-12-04 09:31:06
问题 I have some trouble on getting custom selinux policies running properly on an AOSP based Android 7.1.2 (more precisely based on sony open devices tree). My problem is that the audit logs keep telling me about missing file access rules that I actually added. I also copied rules that audit2allow has created to my policy files, but even those do not properly work. So, let's dig into the details: I created a custom domain called vendor_app . This domain is assigned to an app based on its

Scala, Maven, and preprocessors

Deadly 提交于 2019-12-01 20:52:06
问题 I know all of the philosophical arguments against preprocessors and macros in Java. I don't agree that just because some may abuse a language feature, it should be excluded for all. I would like to include __FILE__ and __LINE__ macros in my Java and Scala code for efficient logging. Any use of Exception is unacceptable because of runtime performance impacts. Those people who argue that logging can be turned off in "production code" should heed the advise of Brian Kernighan: Removing the error