comparison src/c/urweb.c @ 1755:e9587120831a

Run-time CSS style validation
author Adam Chlipala <adam@chlipala.net>
date Sun, 06 May 2012 16:08:48 -0400
parents 6817ddd6cf1f
children 22858505bb2d
comparison
equal deleted inserted replaced
1754:a1380fc15cb5 1755:e9587120831a
4019 } 4019 }
4020 4020
4021 uw_Basis_int uw_Basis_round(uw_context ctx, uw_Basis_float n) { 4021 uw_Basis_int uw_Basis_round(uw_context ctx, uw_Basis_float n) {
4022 return round(n); 4022 return round(n);
4023 } 4023 }
4024
4025 uw_Basis_string uw_Basis_atom(uw_context ctx, uw_Basis_string s) {
4026 char *p;
4027
4028 for (p = s; *p; ++p) {
4029 char c = *p;
4030 if (!isalnum(c) && c != '+' && c != '-' && c != '.' && c != '%' && c != '#')
4031 uw_error(ctx, FATAL, "Disallowed character in CSS atom");
4032 }
4033
4034 return s;
4035 }
4036
4037 uw_Basis_string uw_Basis_css_url(uw_context ctx, uw_Basis_string s) {
4038 char *p;
4039
4040 for (p = s; *p; ++p) {
4041 char c = *p;
4042 if (!isalnum(c) && c != ':' && c != '/' && c != '.' && c != '_' && c != '+'
4043 && c != '-' && c != '%' && c != '?' && c != '&' && c != '=' && c != '#')
4044 uw_error(ctx, FATAL, "Disallowed character in CSS URL");
4045 }
4046
4047 return s;
4048 }
4049
4050 uw_Basis_string uw_Basis_property(uw_context ctx, uw_Basis_string s) {
4051 char *p;
4052
4053 if (!*s)
4054 uw_error(ctx, FATAL, "Empty CSS property");
4055
4056 if (!islower(s[0]) && s[0] != '_')
4057 uw_error(ctx, FATAL, "Bad initial character in CSS property");
4058
4059 for (p = s; *p; ++p) {
4060 char c = *p;
4061 if (!islower(c) && !isdigit(c) && c != '_' && c != '-')
4062 uw_error(ctx, FATAL, "Disallowed character in CSS property");
4063 }
4064
4065 return s;
4066 }