mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 20:16:54 +03:00
Change the scope of some variables picked up by cppcheck, minor reformatting
This commit is contained in:
parent
3ea6ca89a0
commit
5bb5e2667d
@ -189,7 +189,6 @@ void gui_get_clipboard(char **buffer, size_t *length)
|
||||
struct StoredProperty *sp = NULL;
|
||||
ULONG rlen=0,error;
|
||||
struct CSet *cset;
|
||||
LONG codeset = 0;
|
||||
|
||||
if(OpenIFF(iffh,IFFF_READ)) return;
|
||||
|
||||
@ -203,6 +202,7 @@ void gui_get_clipboard(char **buffer, size_t *length)
|
||||
if(ci = FindCollection(iffh, ID_FTXT, ID_UTF8)) {
|
||||
*buffer = ami_clipboard_cat_collection(ci, 106, length);
|
||||
} else if(ci = FindCollection(iffh, ID_FTXT, ID_CHRS)) {
|
||||
LONG codeset = 0;
|
||||
if(sp = FindProp(iffh, ID_FTXT, ID_CSET)) {
|
||||
cset = (struct CSet *)sp->sp_Data;
|
||||
codeset = cset->CodeSet;
|
||||
|
@ -174,7 +174,6 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c)
|
||||
UBYTE *bm_buffer;
|
||||
Object *dto;
|
||||
struct bitmap *bitmap;
|
||||
unsigned int bm_flags = BITMAP_NEW;
|
||||
#ifdef __amigaos4__
|
||||
int bm_format = PBPAFMT_RGBA;
|
||||
#else
|
||||
@ -184,7 +183,7 @@ static struct bitmap *amiga_dt_picture_cache_convert(struct content *c)
|
||||
|
||||
if(dto = amiga_dt_picture_newdtobject(adt))
|
||||
{
|
||||
bitmap = bitmap_create(c->width, c->height, bm_flags);
|
||||
bitmap = bitmap_create(c->width, c->height, BITMAP_NEW);
|
||||
if (!bitmap) {
|
||||
msg_data.error = messages_get("NoMemory");
|
||||
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
|
||||
|
25
amiga/file.c
25
amiga/file.c
@ -149,23 +149,19 @@ void ami_file_save(int type, char *fname, struct Window *win,
|
||||
struct hlcache_handle *object, struct hlcache_handle *favicon,
|
||||
struct browser_window *bw)
|
||||
{
|
||||
BPTR lock = 0;
|
||||
BPTR lock, fh;
|
||||
const char *source_data;
|
||||
ULONG source_size;
|
||||
struct bitmap *bm;
|
||||
BPTR fh=0;
|
||||
|
||||
ami_update_pointer(win, GUI_POINTER_WAIT);
|
||||
|
||||
if(ami_download_check_overwrite(fname, win, 0))
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
if(ami_download_check_overwrite(fname, win, 0)) {
|
||||
switch(type) {
|
||||
case AMINS_SAVE_SOURCE:
|
||||
if((source_data = content_get_source_data(object, &source_size)))
|
||||
{
|
||||
if(fh = FOpen(fname, MODE_NEWFILE,0))
|
||||
{
|
||||
if((source_data = content_get_source_data(object, &source_size))) {
|
||||
BPTR fh;
|
||||
if(fh = FOpen(fname, MODE_NEWFILE,0)) {
|
||||
FWrite(fh, source_data, 1, source_size);
|
||||
FClose(fh);
|
||||
}
|
||||
@ -177,8 +173,7 @@ void ami_file_save(int type, char *fname, struct Window *win,
|
||||
break;
|
||||
|
||||
case AMINS_SAVE_COMPLETE:
|
||||
if(lock = CreateDir(fname))
|
||||
{
|
||||
if(lock = CreateDir(fname)) {
|
||||
UnLock(lock);
|
||||
save_complete(object, fname, ami_file_set_type);
|
||||
amiga_icon_superimpose_favicon(fname, favicon, NULL);
|
||||
@ -193,15 +188,13 @@ void ami_file_save(int type, char *fname, struct Window *win,
|
||||
break;
|
||||
|
||||
case AMINS_SAVE_IFF:
|
||||
if((bm = content_get_bitmap(object)))
|
||||
{
|
||||
if((bm = content_get_bitmap(object))) {
|
||||
bm->url = (char *)nsurl_access(hlcache_handle_get_url(object));
|
||||
bm->title = (char *)content_get_title(object);
|
||||
bitmap_save(bm, fname, 0);
|
||||
}
|
||||
#ifdef WITH_NS_SVG
|
||||
else if(ami_mime_compare(object, "svg") == true)
|
||||
{
|
||||
else if(ami_mime_compare(object, "svg") == true) {
|
||||
ami_save_svg(object, fname);
|
||||
}
|
||||
#endif
|
||||
|
@ -55,9 +55,7 @@ enum
|
||||
const char *fetch_filetype(const char *unix_path)
|
||||
{
|
||||
static char mimetype[50];
|
||||
STRPTR ttype = NULL;
|
||||
struct DiskObject *dobj = NULL;
|
||||
BPTR lock = 0;
|
||||
struct DataType *dtn;
|
||||
BOOL found = FALSE;
|
||||
lwc_string *lwc_mimetype;
|
||||
@ -66,8 +64,7 @@ const char *fetch_filetype(const char *unix_path)
|
||||
We'll just do a filename check here for quickness, although the
|
||||
first word ought to be checked against WB_DISKMAGIC really. */
|
||||
|
||||
if(strncmp(unix_path + strlen(unix_path) - 5, ".info", 5) == 0)
|
||||
{
|
||||
if(strncmp(unix_path + strlen(unix_path) - 5, ".info", 5) == 0) {
|
||||
strcpy(mimetype,"image/x-amiga-icon");
|
||||
found = TRUE;
|
||||
}
|
||||
@ -76,32 +73,26 @@ const char *fetch_filetype(const char *unix_path)
|
||||
/* Secondly try getting a tooltype "MIMETYPE" and use that as the MIME type.
|
||||
Will fail over to default icons if the file doesn't have a real icon. */
|
||||
|
||||
if(!found)
|
||||
{
|
||||
if(!found) {
|
||||
if(dobj = GetIconTags(unix_path,ICONGETA_FailIfUnavailable,FALSE,
|
||||
TAG_DONE))
|
||||
{
|
||||
TAG_DONE)) {
|
||||
STRPTR ttype = NULL;
|
||||
ttype = FindToolType(dobj->do_ToolTypes, "MIMETYPE");
|
||||
if(ttype)
|
||||
{
|
||||
if(ttype) {
|
||||
strcpy(mimetype,ttype);
|
||||
found = TRUE;
|
||||
}
|
||||
|
||||
FreeDiskObject(dobj);
|
||||
}
|
||||
}
|
||||
|
||||
/* If that didn't work, use the MIME file and DataTypes */
|
||||
|
||||
if(!found)
|
||||
{
|
||||
if (lock = Lock (unix_path, ACCESS_READ))
|
||||
{
|
||||
if (dtn = ObtainDataTypeA (DTST_FILE, (APTR)lock, NULL))
|
||||
{
|
||||
if(ami_mime_from_datatype(dtn, &lwc_mimetype, NULL))
|
||||
{
|
||||
if(!found) {
|
||||
BPTR lock;
|
||||
if (lock = Lock (unix_path, ACCESS_READ)) {
|
||||
if (dtn = ObtainDataTypeA (DTST_FILE, (APTR)lock, NULL)) {
|
||||
if(ami_mime_from_datatype(dtn, &lwc_mimetype, NULL)) {
|
||||
strcpy(mimetype, lwc_string_data(lwc_mimetype));
|
||||
found = TRUE;
|
||||
ReleaseDataType(dtn);
|
||||
|
@ -294,7 +294,7 @@ ULONG ami_font_scan_fonts(struct MinList *list,
|
||||
*/
|
||||
ULONG ami_font_scan_list(struct MinList *list)
|
||||
{
|
||||
int afShortage, afSize = 100, i;
|
||||
int afShortage, afSize = 100;
|
||||
struct AvailFontsHeader *afh;
|
||||
struct AvailFonts *af;
|
||||
ULONG found = 0;
|
||||
@ -315,7 +315,7 @@ ULONG ami_font_scan_list(struct MinList *list)
|
||||
if(afh) {
|
||||
af = (struct AvailFonts *)&(afh[1]);
|
||||
|
||||
for(i = 0; i < afh->afh_NumEntries; i++) {
|
||||
for(int i = 0; i < afh->afh_NumEntries; i++) {
|
||||
if(af[i].af_Attr.ta_Style == FS_NORMAL) {
|
||||
if(af[i].af_Attr.ta_Name != NULL) {
|
||||
node = (struct nsObject *)FindIName((struct List *)list,
|
||||
|
@ -126,7 +126,6 @@ void gui_launch_url(const char *url)
|
||||
{
|
||||
APTR procwin = SetProcWindow((APTR)-1L);
|
||||
char *launchurl = NULL;
|
||||
BPTR fptr = 0;
|
||||
|
||||
if(ami_openurl_check_list(&ami_unsupportedprotocols, url) == FALSE)
|
||||
{
|
||||
@ -135,7 +134,7 @@ void gui_launch_url(const char *url)
|
||||
URL_OpenA((STRPTR)url,NULL);
|
||||
} else {
|
||||
if(launchurl = ASPrintf("URL:%s",url)) {
|
||||
fptr = Open(launchurl,MODE_OLDFILE);
|
||||
BPTR fptr = Open(launchurl,MODE_OLDFILE);
|
||||
if(fptr) Close(fptr);
|
||||
else ami_openurl_add_protocol(url);
|
||||
FreeVec(launchurl);
|
||||
|
@ -1093,13 +1093,13 @@ static void ami_menu_item_arexx_entries(struct Hook *hook, APTR window, struct I
|
||||
char *script = hook->h_Data;
|
||||
char *temp;
|
||||
struct gui_window_2 *gwin;
|
||||
BPTR lock = 0;
|
||||
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
||||
|
||||
if(script)
|
||||
{
|
||||
if(temp = AllocVecTagList(1024, NULL))
|
||||
{
|
||||
BPTR lock;
|
||||
if(lock = Lock(nsoption_charp(arexx_dir), SHARED_LOCK)) {
|
||||
DevNameFromLock(lock, temp, 1024, DN_FULLPATH);
|
||||
AddPart(temp, script, 1024);
|
||||
@ -1110,3 +1110,4 @@ static void ami_menu_item_arexx_entries(struct Hook *hook, APTR window, struct I
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,6 @@ void warn_user(const char *warning, const char *detail)
|
||||
Object *req = NULL;
|
||||
char *utf8warning = ami_utf8_easy(messages_get(warning));
|
||||
STRPTR bodytext = NULL;
|
||||
LONG result = 0;
|
||||
|
||||
LOG(("%s %s", warning, detail));
|
||||
|
||||
@ -63,7 +62,7 @@ void warn_user(const char *warning, const char *detail)
|
||||
TAG_DONE);
|
||||
|
||||
if (req) {
|
||||
result = IDoMethod(req, RM_OPENREQ, NULL, NULL, scrn);
|
||||
LONG result = IDoMethod(req, RM_OPENREQ, NULL, NULL, scrn);
|
||||
DisposeObject(req);
|
||||
}
|
||||
|
||||
|
@ -473,8 +473,6 @@ bool ami_polygon(const int *p, unsigned int n, const plot_style_t *style)
|
||||
LOG(("[ami_plotter] Entered ami_polygon()"));
|
||||
#endif
|
||||
|
||||
int k;
|
||||
|
||||
if((nsoption_int(cairo_renderer) < 1) || (palette_mapped == true))
|
||||
{
|
||||
ULONG cx,cy;
|
||||
@ -484,7 +482,7 @@ bool ami_polygon(const int *p, unsigned int n, const plot_style_t *style)
|
||||
if(AreaMove(glob->rp,p[0],p[1]) == -1)
|
||||
LOG(("AreaMove: vector list full"));
|
||||
|
||||
for(k=1;k<n;k++)
|
||||
for(int k = 1; k < n; k++)
|
||||
{
|
||||
if(AreaDraw(glob->rp,p[k*2],p[(k*2)+1]) == -1)
|
||||
LOG(("AreaDraw: vector list full"));
|
||||
@ -501,7 +499,7 @@ bool ami_polygon(const int *p, unsigned int n, const plot_style_t *style)
|
||||
|
||||
cairo_set_line_width(glob->cr, 0);
|
||||
cairo_move_to(glob->cr, p[0], p[1]);
|
||||
for (k = 1; k != n; k++) {
|
||||
for (int k = 1; k != n; k++) {
|
||||
cairo_line_to(glob->cr, p[k * 2], p[k * 2 + 1]);
|
||||
}
|
||||
cairo_fill(glob->cr);
|
||||
|
@ -289,7 +289,7 @@ void ami_init_mouse_pointers(void)
|
||||
|
||||
for(i=0;i<=AMI_LASTPOINTER;i++)
|
||||
{
|
||||
BPTR ptrfile = 0;
|
||||
BPTR ptrfile;
|
||||
mouseptrbm[i] = NULL;
|
||||
mouseptrobj[i] = NULL;
|
||||
char ptrfname[1024];
|
||||
|
Loading…
Reference in New Issue
Block a user