Improve libqhtml build

- add dependencies
- support expression syntax in csstoqe
This commit is contained in:
Charlie Gordon 2021-02-03 09:03:51 +01:00
commit e2e290ec72
3 changed files with 35 additions and 7 deletions

View file

@ -56,6 +56,10 @@
* tags: remove tags for modified line
* undo: undo some cursor movements
* xml: merge xml and htmlsrc modes, add submodes for plist and other config files
* tack library of ancillary files at the end of the binary:
- add protocol to read from library (lib:xxx)
- add html.min.css and docbook.min.css to library
- append lib: to default QE_PATH
## Priority 0

View file

@ -77,6 +77,7 @@ OBJS= css.o xmlparse.o cssparse.o html_style.o docbook_style.o
DEPENDS:= qe.h config.h cutils.h display.h qestyles.h config.mak
DEPENDS:= $(addprefix $(DEPTH)/, $(DEPENDS))
DEPENDS+= css.h cssid.h htmlent.h
BINDIR:=$(DEPTH)/bin

View file

@ -20,9 +20,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
static int peekc(FILE *f)
{
@ -32,6 +33,26 @@ static int peekc(FILE *f)
return c;
}
static int compat_char(int c1, int c2)
{
if ((isalnum(c1) || c1 == '_' || c1 == '$')
&& (isalnum(c2) || c2 == '_' || c2 == '$'))
return 0;
if ((c1 == c2 && strchr("+-<>&|=", c1))
|| (c2 == '=' && strchr("<>!+-*/&|^%", c1))
|| (c1 == '-' && c2 == '>')
|| (c1 == '/' && c2 == '/')
|| (c1 == '/' && c2 == '*')
|| (c1 == '*' && c2 == '/')
|| (c1 == '<' && c2 == '/')
|| (c1 == '.' && isdigit(c2))
|| (isdigit(c1) && c2 == '.'))
return 0;
return 1;
}
int main(int argc, char **argv)
{
int c, n, last_c, got_space, in_string;
@ -95,18 +116,20 @@ int main(int argc, char **argv)
printf(" \"");
}
/* add separator if needed */
if (!in_string && got_space && isalnum(c) && isalnum(last_c)) {
putchar(' ');
n++;
if (!in_string && got_space) {
if (!compat_char(last_c, c)) {
putchar(' ');
n++;
}
}
if (c == '\"' || c == '\'' || c == '\\') {
putchar('\\');
n++;
}
putchar(c);
if (c == '\"') {
/* CG: does not work for ' ' */
in_string ^= 1;
if (c == '\"' || c == '\'') {
if (in_string == c || in_string == 0)
in_string ^= c;
}
last_c = c;
got_space = 0;