Commit 92a69868 authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

Fix bad merge. Improve Get_DTD_ASCII & MDF saving.

Detail:
  c/ScrModes - Fix a bad merge causing a compute_modedescription() call to go missing. Fix Get_DTD_ASCII to avoid reading one byte too many, and to ensure the buffer is null terminated. Also strip any control characters. Improve MDF saving to return an error if the file couldn't be created, and to substitute various unsafe characters with underscores
Admin:
  Tested on Pandaboard


Version 0.46. Tagged as 'ScrModes-0_46'
parent 16d50f7d
/* (0.45) /* (0.46)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1. * Last processed by srccommit version: 1.1.
* *
*/ */
#define Module_MajorVersion_CMHG 0.45 #define Module_MajorVersion_CMHG 0.46
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 16 Feb 2015 #define Module_Date_CMHG 16 Feb 2015
#define Module_MajorVersion "0.45" #define Module_MajorVersion "0.46"
#define Module_Version 45 #define Module_Version 46
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "16 Feb 2015" #define Module_Date "16 Feb 2015"
...@@ -18,6 +18,6 @@ ...@@ -18,6 +18,6 @@
#define Module_ComponentName "ScrModes" #define Module_ComponentName "ScrModes"
#define Module_ComponentPath "castle/RiscOS/Sources/Video/UserI/ScrModes" #define Module_ComponentPath "castle/RiscOS/Sources/Video/UserI/ScrModes"
#define Module_FullVersion "0.45" #define Module_FullVersion "0.46"
#define Module_HelpVersion "0.45 (16 Feb 2015)" #define Module_HelpVersion "0.46 (16 Feb 2015)"
#define Module_LibraryVersionInfo "0:45" #define Module_LibraryVersionInfo "0:46"
...@@ -1659,19 +1659,26 @@ static _kernel_oserror *Check_EDID_Checksum(char *EDIDData, char check_type) ...@@ -1659,19 +1659,26 @@ static _kernel_oserror *Check_EDID_Checksum(char *EDIDData, char check_type)
/* Get_DTD_ASCII takes a block of text from an 18-byte EDID data block /* Get_DTD_ASCII takes a block of text from an 18-byte EDID data block
* And fills a supplied character buffer with a usable 0-terminated string * And fills a supplied character buffer with a usable 0-terminated string
* Buffer must be at least 14 bytes in length
*/ */
static void Get_DTD_ASCII(EDIDBlockRef edidblockref, int block_number, char *data) static void Get_DTD_ASCII(EDIDBlockRef edidblockref, int block_number, char *data)
{ {
int i; int i;
for (i = 0; i < 14; ++i) for (i = 0; i < 13; ++i)
{ {
data[i] = edidblockref->data_block[block_number][i+5]; data[i] = edidblockref->data_block[block_number][i+5];
if (data[i] == 0x0A) if (data[i] == 0x0A)
{ {
data[i] = 0; break;
}
else if ((data[i] < 32) || (data[i] == 127))
{
/* Strip out any control characters for safety */
data[i] = ' ';
} }
} }
data[i] = 0;
} }
static void generate_mode_using_gtf(double h_pixels, double v_lines, double ip_freq_rqd, ModeDescriptionRef mode_desc, MonitorDescriptionRef monitor) static void generate_mode_using_gtf(double h_pixels, double v_lines, double ip_freq_rqd, ModeDescriptionRef mode_desc, MonitorDescriptionRef monitor)
...@@ -2097,7 +2104,6 @@ static void generate_mode_using_cvt_rb(double h_pixels, double v_lines, double i ...@@ -2097,7 +2104,6 @@ static void generate_mode_using_cvt_rb(double h_pixels, double v_lines, double i
/* Now populate the mode definition block */ /* Now populate the mode definition block */
mode_desc->definition.xres = (int)h_pixels; mode_desc->definition.xres = (int)h_pixels;
mode_desc->definition.yres = (int)v_lines; mode_desc->definition.yres = (int)v_lines;
mode_desc->frame_hz = (int)ip_freq_rqd;
mode_desc->definition.hpar[FR_SYNC] = h_sync; mode_desc->definition.hpar[FR_SYNC] = h_sync;
mode_desc->definition.hpar[FR_BPCH] = h_back_porch; mode_desc->definition.hpar[FR_BPCH] = h_back_porch;
mode_desc->definition.hpar[FR_BDR1] = (int) left_margin; mode_desc->definition.hpar[FR_BDR1] = (int) left_margin;
...@@ -2256,6 +2262,7 @@ static void dtd_block_to_modedesc(char* dtd_data, ModeDescriptionRef mode_desc) ...@@ -2256,6 +2262,7 @@ static void dtd_block_to_modedesc(char* dtd_data, ModeDescriptionRef mode_desc)
} }
sprintf(mode_desc->definition.name, "%d x %d", mode_desc->definition.xres, mode_desc->definition.yres); sprintf(mode_desc->definition.name, "%d x %d", mode_desc->definition.xres, mode_desc->definition.yres);
compute_modedescription(mode_desc);
#if DODEBUG #if DODEBUG
display_mode_parameters(mode_desc); display_mode_parameters(mode_desc);
...@@ -2537,21 +2544,21 @@ static _kernel_oserror *parseedid(char *ediddata, const char *file) ...@@ -2537,21 +2544,21 @@ static _kernel_oserror *parseedid(char *ediddata, const char *file)
/* file is a string terminated in 0x0D */ /* file is a string terminated in 0x0D */
char *ptr,*fbuf; char *ptr,*fbuf;
int length=strcspn(file,"\r"); int length=strcspn(file,"\r");
res = _swix(OS_Module, _IN(0) | _IN(3) | _OUT(2), 6, length+24, &fbuf); fbuf = malloc(length+MAXMONITORNAME+2);
/* get around the CR terminated file name */ /* get around the CR terminated file name */
if(!res) { if(fbuf) {
fbuf[length] = 0; memcpy(fbuf,file,length);
while((--length)>=0){ fbuf[length] = '.';
fbuf[length] = file[length]; strcpy(fbuf+length+1,new_monitor->name);
} while(ptr=strpbrk(fbuf+length+1," \"#$%&*.:@\\^|\x7f<>"),ptr) {
strcat (fbuf,".");
strncat (fbuf,new_monitor->name,22);
while(ptr=strpbrk(fbuf," "),ptr) {
*ptr='_'; *ptr='_';
} }
f=fopen(fbuf,"w"); f=fopen(fbuf,"w");
res = _swix(OS_Module, _IN(0) |_IN(2) , 7, fbuf); free(fbuf);
}
if(!f) {
return _kernel_last_oserror();
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment