From owner-svn-src-all@freebsd.org Fri Feb 16 16:37:39 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2CE9BF2321F for ; Fri, 16 Feb 2018 16:37:39 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x229.google.com (mail-it0-x229.google.com [IPv6:2607:f8b0:4001:c0b::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AC53F8447B for ; Fri, 16 Feb 2018 16:37:38 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x229.google.com with SMTP id 193so2447382iti.1 for ; Fri, 16 Feb 2018 08:37:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=IAS4hNilnPgjonYhMZABZ/Bvn369ymYEN3iJhTjkIvA=; b=y4Bn5T1RH2T5HGPLqfEulD3OtDthzOOl81/DQ7YKVQoZtkp0YK+1d6ND9N/Tg/k66s iXiPJ5s2Ql6ukxu2BSvIRa4RxRQDaYn+cZ3DWXR+BhJYaS5aD40VoOGKDunzaX6+v6zj QKh7y5g2PrTZHqGczno0IJ70QS+MZLpvinUn3JPOyd5bJvvdc1i+ZkXkKZeaVCba38YW AY8z1BtyQESqO6lQOnELgVNhs2sd2fN6sY9rnP3bcPC7CAOkUzE28Fd2Np37QGfkjxAp Uc372Z4Kathcbsgikur+6F1u5KL/4nFpc9onxIL1jb6hSXdVexRzukIghRtdYbIsfrq+ /fJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=IAS4hNilnPgjonYhMZABZ/Bvn369ymYEN3iJhTjkIvA=; b=kbdpGZuRpyhTosPsO2BqEmfIqFKPq6y3mD3hIx3VoGJWkFhLXzBy5pI3x1uUzvtILI wnY6gqetvbr1Uch4hItnDxbNst2AVvvtJvsmwLTNdpx5TG59tCyhssB758TEwbcMJSTl oTjVrlFx4Hv4E6SMUXWiwlev0bEdvbX9wnZQDD5MCAV+HbVhRT2BpeodfKoWF3jMXVwQ pxa3LIV0bV+G66mboGrmO/Tws+mcx/qRmvdzibfy1C8dqICHhBfNEhCzsd9yZcA9KdbE ZJvYsKY66guok+5uVmsuUglv1x+ZWbGyOvnsL7sEYRIx3cGwxgdlOboGxnBL8fg3amoH Oz3g== X-Gm-Message-State: APf1xPAvt1j8pXrLTNxLCPowfzNx2b8W2r/NYsZyn1u+qj+YjQhH0b7M xbN0aqGLMkzc8wAxMlI/8beG44vaYjyYUO5g/uklzQ== X-Google-Smtp-Source: AH8x227btpQZvFvT6spPG1h9AAdhIQRDFFEwhGNnJi61PFnV4htUKx0eMbRjtKF5IfdN/4eBntSqqoNzbwYxdUlON58= X-Received: by 10.36.201.66 with SMTP id h63mr6572248itg.36.1518799057999; Fri, 16 Feb 2018 08:37:37 -0800 (PST) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.201.67 with HTTP; Fri, 16 Feb 2018 08:37:37 -0800 (PST) X-Originating-IP: [50.253.99.174] In-Reply-To: References: <201802160312.w1G3CO3r085739@repo.freebsd.org> From: Warner Losh Date: Fri, 16 Feb 2018 09:37:37 -0700 X-Google-Sender-Auth: C7x2lwvvtYTVkghKhJLE6gNzFFE Message-ID: Subject: Re: svn commit: r329349 - head/stand/lua To: Kyle Evans Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Feb 2018 16:37:39 -0000 On Feb 16, 2018 6:58 AM, "Kyle Evans" wrote: On Thu, Feb 15, 2018 at 9:12 PM, Kyle Evans wrote: > Author: kevans > Date: Fri Feb 16 03:12:24 2018 > New Revision: 329349 > URL: https://svnweb.freebsd.org/changeset/base/329349 > > Log: > stand/lua: Reduce magic numbers > > Enter/backspace values are hardcoded in both the menu and password scripts. > Separate these out to core for reuse between the two. > > Modified: > head/stand/lua/core.lua > head/stand/lua/menu.lua > head/stand/lua/password.lua > > Modified: head/stand/lua/core.lua > ============================================================ ================== > --- head/stand/lua/core.lua Fri Feb 16 01:33:01 2018 (r329348) > +++ head/stand/lua/core.lua Fri Feb 16 03:12:24 2018 (r329349) > @@ -28,6 +28,10 @@ > > local core = {}; > > +-- Commonly appearing constants > +core.KEY_ENTER = 13 > +core.KEY_BACKSPACE = 127 > + > function core.setVerbose(b) > if (b == nil) then > b = not core.verbose; > > Modified: head/stand/lua/menu.lua > ============================================================ ================== > --- head/stand/lua/menu.lua Fri Feb 16 01:33:01 2018 (r329348) > +++ head/stand/lua/menu.lua Fri Feb 16 03:12:24 2018 (r329349) > @@ -273,9 +273,9 @@ function menu.run(m) > local key = io.getchar(); > > -- Special key behaviors > - if (key == 127) and (m ~= menu.welcome) then > + if (key == core.KEY_BACKSPACE) and (m ~= menu.welcome) then > break > - elseif (key == 13) then > + elseif (key == core.KEY_ENTER) then > core.boot(); > -- Should not return > end > @@ -357,7 +357,7 @@ function menu.autoboot() > screen.defcursor(); > if io.ischar() then > local ch = io.getchar(); > - if ch == 13 then > + if ch == core.KEY_ENTER then > break; > else > -- prevent autoboot when escaping to interpreter > > Modified: head/stand/lua/password.lua > ============================================================ ================== > --- head/stand/lua/password.lua Fri Feb 16 01:33:01 2018 (r329348) > +++ head/stand/lua/password.lua Fri Feb 16 03:12:24 2018 (r329349) > @@ -37,11 +37,11 @@ function password.read() > > repeat > ch = io.getchar(); > - if ch == 13 then > + if ch == core.KEY_ENTER then > break; > end > > - if ch == 8 then > + if ch == core.KEY_BACKSPACE then It's worth noting that this changes the comparison from 'ch == 8' to 'ch == 127'. The password prompt was non-functional on my test systems until this change, because I can never type my password right the first time. =) Pointed out by: cem@ History has shown we likely want to accept both BS (8) and DEL (127) as logical 'backwards erase character' signals. Warner