From 92ff4cdf8c84e91584dd6076aa5b3c774ab0a622 Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Mon, 5 Aug 2024 02:45:17 +0000 Subject: automatic import of hplip --- hplip-model-mismatch.patch | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 hplip-model-mismatch.patch (limited to 'hplip-model-mismatch.patch') diff --git a/hplip-model-mismatch.patch b/hplip-model-mismatch.patch new file mode 100644 index 0000000..1dbe3c0 --- /dev/null +++ b/hplip-model-mismatch.patch @@ -0,0 +1,64 @@ +diff --git a/io/hpmud/jd.c b/io/hpmud/jd.c +index 20df27a..7ed4918 100644 +--- a/io/hpmud/jd.c ++++ b/io/hpmud/jd.c +@@ -208,7 +208,22 @@ enum HPMUD_RESULT __attribute__ ((visibility ("hidden"))) jd_open(mud_device *pd + { + /* Make sure uri model matches device id model. */ + hpmud_get_uri_model(pd->uri, uri_model, sizeof(uri_model)); ++ ++ /* remove possible hp_ string */ ++ if (strncasecmp(uri_model, "HP_", 3) == 0) ++ { ++ memmove(uri_model, uri_model + 3, 127); ++ uri_model[127] = '\0'; ++ } ++ + hpmud_get_model(pd->id, model, sizeof(model)); ++ /* remove possible hp_ string */ ++ if (strncasecmp(model, "HP_", 3) == 0) ++ { ++ memmove(model, model + 3, 127); ++ model[127] = '\0'; ++ } ++ + if (strcasecmp(uri_model, model) != 0) + { + stat = HPMUD_R_INVALID_URI; /* different device plugged in */ +diff --git a/io/hpmud/model.c b/io/hpmud/model.c +index d546ec1..adb3d87 100644 +--- a/io/hpmud/model.c ++++ b/io/hpmud/model.c +@@ -407,7 +407,10 @@ static int ParseFile(char *datFile, char *model, char *attr, int attrSize, int * + char rcbuf[255]; + char section[128]; + char file[128]; +- int found=0, n; ++ int found=0; ++ size_t n; ++ ++ size_t model_len = strlen(model); + + if ((fp = fopen(datFile, "r")) == NULL) + goto bugout; +@@ -422,10 +425,17 @@ static int ParseFile(char *datFile, char *model, char *attr, int attrSize, int * + strncpy(section, rcbuf+1, sizeof(section)); /* found new section */ + n = strlen(section); + section[n-2]=0; /* remove ']' and CR */ ++ n -= 2; + if (strcasecmp(model, section) == 0 || +- (section[0] == 'h' && section[1] == 'p' && +- section[2] == '_' && +- strcasecmp(model, section + 3) == 0)) ++ (section[0] == 'h' && ++ section[1] == 'p' && ++ section[2] == '_' && ++ strcasecmp(model, section + 3) == 0) || ++ (n > model_len && ++ strncasecmp(section, model, model_len) == 0 && ++ strncasecmp(section + model_len, "_series", strlen("_series")) == 0 ++ ) ++ ) + { + /* Found model match. */ + *bytes_read = ResolveAttributes(fp, attr, attrSize); -- cgit v1.2.3